Skip to content

validation error The inputName field must be true or false. #53486

Closed Answered by bayukartiko
bayukartiko asked this question in Q&A
Discussion options

You must be logged in to vote

for temporary solution:

add this in AppServiceProvider.php

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: 'inputName' => ['required', 'isBoolean']

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bayukartiko
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant