Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Schema Laravel Package

justinrainbow/json-schema

Validate JSON documents against JSON Schema in PHP. Supports Draft-3, Draft-4, Draft-6 and Draft-7 (coverage varies). Install via Composer and use JsonSchema\Validator to validate data with local file $ref schemas and inspect validation errors.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel Compatibility: Remains unchanged. The package’s PHP-based implementation continues to integrate seamlessly with Laravel’s service container and dependency injection.
  • Schema Validation Use Cases: No impact on core validation capabilities (API requests, form submissions, database input). Draft 7 support remains the de facto standard.
  • Draft Support: No changes to supported draft versions (3, 4, 6, 7). Future-proofing intact.
  • Type Coercion: Unaffected. Critical for Laravel’s input handling (e.g., string-to-boolean conversion).

Integration Feasibility

  • Composer Integration: No breaking changes to installation. composer require remains frictionless.
  • Service Provider/Facade: No modifications needed to existing Laravel wrappers (e.g., Schema::validate()).
  • Event-Driven Hooks: Laravel event integration (e.g., Illuminate\Http\Request) remains viable.

Technical Risk

  • Performance Overhead: Unchanged. Benchmarking still required for high-throughput APIs (>10k RPS).
  • Schema Complexity: No new risks introduced. Circular references or nested schemas remain potential bottlenecks.
  • Type Coercion Side Effects: No changes to coercion behavior. Laravel’s immutable data patterns may still conflict.
  • Draft 7 Limitations: Unaffected. Advanced features (e.g., conditional validation) may still require custom extensions.
  • Error Handling: No updates to error formats. Laravel’s ValidationException adaptation remains necessary.

Key Questions

  1. Validation Granularity: Unchanged. Still depends on team preference (controller/middleware/service layer).
  2. Schema Storage: Unchanged. Filesystem/database/remote options remain valid.
  3. Error Presentation: Unchanged. JSON Schema → Laravel MessageBag mapping still required.
  4. Caching: Unchanged. Schema/validation result caching strategies unchanged.
  5. Testing Strategy: Unchanged. Unit/feature tests with Http::fake() remain applicable.
  6. Draft Versioning: Unchanged. Multi-draft support still optional.
  7. Laravel Validation Integration: Unchanged. Complementary use with Illuminate\Validation\Validator still recommended.
  8. Async Validation: Unchanged. Remote schema validation may still need queuing.

UPDATED QUESTIONS DUE TO RELEASE NOTES: 9. Test Suite Alignment:

  • The release references an update to the "json schema test suite main branch." Does this imply:
    • New compliance requirements for schemas (e.g., stricter validation rules)?
    • Potential breaking changes in error reporting or validation logic?
    • Need to revalidate existing schemas against the updated test suite?
  • Action: Verify if existing schemas pass the new test suite. If not, update schemas or adjust Laravel error handling.

Integration Approach

Stack Fit

  • Laravel Ecosystem: Unchanged. Form Requests, API Resources, and middleware integration remain viable.
  • Testing Tools: Unchanged. Pest/Laravel/Dusk compatibility unaffected.
  • Monitoring: Unchanged. Sentry/Horizon logging still applicable.

Migration Path

  1. Phase 1: PoC: Unchanged. Install, test with 2–3 schemas, benchmark.
  2. Phase 2: Core Integration: Unchanged. Service provider, facade, Form Request integration.
  3. Phase 3: Scaling: Unchanged. Add caching, async validation, error handling.
    • NEW STEP: Schema Compliance Check:
      • Run existing schemas through the updated test suite.
      • Log warnings/errors for non-compliant schemas.
      • Prioritize fixes for critical paths (e.g., user authentication).

Compatibility

  • Laravel Versions: Unchanged. Compatible with 8+ (PHP 7.4+) and 9/10 (PHP 8.0+).
  • PHP Extensions: Unchanged. json/intl still recommended.
  • Existing Validation: Unchanged. Coexistence with Laravel’s validator remains possible.
  • Database Schemas: Unchanged. JSON/JSONB or LONGTEXT still required.

Sequencing

Step Task Dependencies
1 Install package Composer
2 Implement basic validator justinrainbow/json-schema
3 NEW: Validate schemas against updated test suite Updated test suite
4 Create service provider Laravel service container
5 Integrate with Form Requests Illuminate\Foundation\Http\FormRequest
6 Add caching (Redis) Laravel cache config
7 Extend error handling Laravel validation exceptions
8 Benchmark performance Load testing tools (e.g., k6)
9 Document schema standards Team documentation

Operational Impact

Maintenance

  • Schema Updates:
    • NEW: Add a compliance check step in CI/CD to validate schemas against the updated test suite.
    • Example GitHub Action:
      - name: Validate JSON Schemas
        run: php artisan schema:test --suite=main
      
    • Version schemas with compliance tags (e.g., v1.0-test-suite-v2.json).
  • Dependency Updates:
    • NEW: Pin justinrainbow/json-schema to 6.8.2 in composer.json to avoid test suite regressions.
    • Monitor for future test suite updates that may introduce breaking changes.
  • Constraint Modes: Unchanged. Document globally enabled modes (e.g., CHECK_MODE_COERCE_TYPES).

Support

  • Error Debugging:
    • NEW: Updated test suite may produce different error formats or additional validation rules.
      • Example: A previously accepted schema might now fail for "unexpected property X" due to stricter test suite rules.
      • Action: Log raw JSON Schema errors to Sentry with a test_suite_version tag.
    • Translate errors to Laravel’s MessageBag as before, but account for new error types.
  • Schema Registry:
    • NEW: Add a compliance_status field to the registry (e.g., ["api/v1/users" => ["schema" => "user_v1.json", "status" => "compliant"]]).
    • Flag non-compliant schemas in monitoring dashboards (e.g., Grafana).

Scaling

  • Performance: Unchanged. No evidence of performance regressions in release notes.
  • Failure Modes:
    • NEW: Schema compliance failures may now occur during CI, blocking deployments.
      • Mitigation: Gradually migrate schemas to compliance or suppress warnings for legacy schemas with deprecation timelines.
    • Existing: Circular references or deep nesting may still cause timeouts.

Ramp-Up

  • Onboarding:
    • NEW: Document the updated test suite requirements in the team’s schema design guide.
      • Example: "Avoid additionalProperties: true if the test suite enforces strict property validation."
    • Provide a compliance checklist for new schemas (e.g., "Passes test suite v2," "No circular references").
  • Training:
    • NEW: Conduct a 30-minute sync to review:
      • Changes in the test suite (e.g., new validation rules).
      • Updated error handling workflows.
      • CI compliance checks.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope