Skip to content

Released version 1.3.6

Latest

Choose a tag to compare

@dg dg released this 17 Aug 18:17
· 20 commits to master since this release

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.