You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(state): skip the filter for empty parameter values
Add a skipFilterOnEmpty option on Parameter, defaulting to true. An empty
string value is kept, so validation still runs and can return a 422, but
the Doctrine ORM/ODM ParameterExtension does not call the filter for it,
avoiding driver-specific errors (e.g. PostgreSQL rejecting '' for an
integer column). Set it to false to call the filter with the raw value.
ValueCaster no longer casts empty strings (reverted): an empty value is a
present-but-valueless parameter, distinct from a typed zero/false and from
an absent parameter.
Copy file name to clipboardExpand all lines: src/Metadata/Parameter.php
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ abstract class Parameter
42
42
* @param ?bool $castToNativeType whether API Platform should cast your parameter to the nativeType declared
43
43
* @param ?callable(mixed): mixed $castFn the closure used to cast your parameter, this gets called only when $castToNativeType is set
44
44
* @param ?string $filterClass the class to use when resolving filter properties (from stateOptions)
45
+
* @param ?bool $skipFilterOnEmpty when true (the default), the filter is not called for an empty string value (validation still runs); set to false to call the filter with the raw empty value (the filter must then handle it)
0 commit comments