Weave 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

Schema Laravel Package

nette/schema

Nette Schema is a lightweight PHP library for validating and normalizing structured data. Define schemas to check arrays and objects, coerce values, and generate clear error messages for configs, APIs, and form input.

View on GitHub
Deep Wiki
Context7
v1.3.6

A round of fixes to the corners of the validation pipeline that only bite once your schema gets interesting: nullable arrays, invalid keys, deprecated items and anyOf() branches. On top of that, castTo() now speaks backed enums.

✨ New Features

  • castTo() now accepts a backed enum – Expect::string()->castTo(Status::class) converts the value via Status::from() and, when it doesn't match, reports a proper validation error listing all allowed cases instead of blowing up with a ValueError. Pure (non-backed) enums are rejected up front with a clear message.
  • Casting to a class that can't swallow the given value no longer surfaces as a bare Error – you get an InvalidStateException naming the target class, so you know what failed to be constructed.

🐛 Bug Fixes

  • A null value for a nullable array is finally left as null. Previously the "NEON can't tell null from an empty array" workaround kicked in even for schemas explicitly declared nullable(), silently turning your null into [].
  • Items with an invalid key are now dropped instead of being merged together – all failing keys used to collapse into a single '' entry, quietly overwriting each other's values.
  • Processor::getWarnings() no longer dies with an error when called before anything was processed; it simply returns an empty array.
  • deprecated() on a required structure no longer emits a warning when the item isn't present in the input at all – you only get warned about deprecated items you actually used.
  • anyOf() stopped losing information in the winning branch: dynamic parameters found inside are propagated to the outer context again (they used to be silently forgotten, so DI never validated them), and skipDefaults is now honored inside the branch. A DynamicParameter schema also no longer registers itself for deferred validation.
  • Error messages keep unknown %placeholders% intact instead of tripping over an undefined index.
v1.3.5

A code quality release that tightens static analysis and cleans up internals.

  • Fixed all PHPStan errors and improved phpDoc annotations
  • Switched to singleline declare statements across the codebase
v1.3.4

improved phpDoc

v1.3.3
  • support for PHP 8.5
  • optimized global function calls
v1.3.2
  • support for PHP 8.4
  • added Structure::extend() #66
  • added Structure::getShape() #35
  • Expect::array(shape) returns Structure
  • Structure::merge() without otherItems it merges by overwriting
v1.3.0
  • requires PHP 8.1
  • uses PHP 8.1 features
v1.2.5
  • added transform() #52
  • castTo() allows you to create objects #44 #47 #58 #46
  • refactoring
  • added path to Context::$dynamics
  • Base: removed DynamicParameter from error message
v1.2.4
  • support for PHP 8.3
  • constants are PascalCase
v1.2.3
  • support for PHP 8.2
  • cs
v1.2.2
  • supports nette/utils 2.5
v1.2.0
  • Structure::skipDefaults() allow to skip defaults per structure
  • AnyOf() must not be empty
  • added AnyOf::firstIsDefault()
  • Ability to define scheme for the key Expert::arrayOf($stringType, $keyType)
v1.1.0
  • added Type::mergeDefaults() [Closes #13, Closes #24, Closes #28, Closes #31]
  • added error codes
  • ValidationException::getMessageObjects() returns array of Messages
  • Allow options to be marked as deprecated [Closes #27]
  • Structure: structure with required fields can be optional [Closes #17]
  • Type: PREVENT_MERGING prevents merging with defaults [Closes #14, Closes nette/application#257, nette/di#229]
  • 'option' changed to 'item' in error messages
v1.0.4
  • Context is not internal #29
  • AnyOf: calls normalize() on items #25 #18
  • Structure: range is ?int, ?int #20
  • fixed combination of range with nullable/dynamic #32 #23
  • Type: ignore pattern when value is null

For the details you can have a look at the diff.

v1.0.3
  • compatible with PHP 8
  • Expect::from() supports union types
  • coding style
  • tests: refactoring

For the details you can have a look at the diff.

v1.0.2
  • Assert with optinal description #7 (#8)
  • Base::required() accepts state parameter (#16)

For the details you can have a look at the diff.

v1.0.1
  • AnyOf: default value can be Schema (#12)
  • Structure: is normalized to array in normalize() #9
  • Added support for pattern() (#6)

For the details you can have a look at the diff.

v1.0.0

Handy library for validating data structures against a given Schema is here! :-)

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.
laravel2580/idehelpers
delatbabel/viewpages
anavel/gettext
muhamadrezaar/highcharts
delatbabel/keylists
frankkessler/salesforce-laravel-oauth2-rest
anavel/foundation
wdmtech/enviricons
eii/laravel-captcha
muka/shape-reader
tdt/json
refinery29/php-cs-fixer-config
hotmeteor/eco-env
mvaliolahi/hydrate
wearede/tbcpay-php
parsnick/steak
thibaud-dauce/mattermost-php
multilinguals/apollo-client
antaresbr/collection
kr0lik/phpstan-rules