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
Hi,
Firstly, I know there are accepted and rejected validators, but....
The $request->boolean() method uses FILTER_VALIDATE_BOOLEAN which in turn returns ‘1’, ‘true’, ‘on’ and ‘yes’ for true. The boolean validator on the other hand only uses true, 1 and ‘1’. This causes an inconsistency for e.g. checkboxes (but also for the Postgres database, for which the boolean true is 1, true, on, yes), because a checked checkbox will be rejected by the validator, but $request->boolean(‘checkbox’) will return true/false for on/off.
Wouldn't it be better to make this behaviour consistent and thus simplify the validation too?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Firstly, I know there are accepted and rejected validators, but....
The $request->boolean() method uses FILTER_VALIDATE_BOOLEAN which in turn returns
‘1’, ‘true’, ‘on’ and ‘yes’
for true. The boolean validator on the other hand only usestrue, 1 and ‘1’
. This causes an inconsistency for e.g. checkboxes (but also for the Postgres database, for which the boolean true is1, true, on, yes
), because a checked checkbox will be rejected by the validator, but $request->boolean(‘checkbox’) will return true/false for on/off.Wouldn't it be better to make this behaviour consistent and thus simplify the validation too?
Beta Was this translation helpful? Give feedback.
All reactions