validation error The inputName field must be true or false.
#53486
-
if the value is string why not use If this is not feasible, could someone submit a PR to add support for these values on method_validateBoolean? Thank you for considering this! current laravel version: 11.31.0 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
for temporary solution: add this in Str::macro("toBoolean", function($value){
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
});
Validator::extend('isBoolean', function($attribute, $value, $parameters) {
return is_bool(Str::toBoolean($value));
}, 'The :attribute field must be true or false.'); use in validation rule like: |
Beta Was this translation helpful? Give feedback.
-
related discussion #53489 |
Beta Was this translation helpful? Give feedback.
for temporary solution:
add this in
AppServiceProvider.php
use in validation rule like:
'inputName' => ['required', 'isBoolean']