Closed jakobmats closed 3 years ago
The following syntax will be used because "as" is a keyword :roll_eyes:
$ctx['name']->to('string')->unwrap();
$ctx['age']->to('int')->unwrapOrNull();
$ctx['age']->to('int')->unwrapOr(0);
$ctx['price']->to('float')->unwrapOrThrow(new \InvalidArgumentException());
Also, I'm afraid that context and context injecting will need to be reworked so that validator registry can be stored inside context objects.
Things that can be retrieved from context objects using array access should be exposed as wrapped values that can be validated against some criteria. My suggestion is something along the lines of:
This will make path parameters more secure and robust.