Support the ongoing development of Laravel.io →
posted 10 years ago
Validation

I've trying out the new boolean validation rule in 4.2.3: http://laravel.com/docs/validation#rule-boolean

// Validation rules public static $rules = array( 'administrator' => 'sometimes|required|boolean', 'payer' => 'sometimes|required|boolean', );

When my validation fails; the default error message returned is simply "validation.boolean".

I've tried creating a custom error message on my model but it doesn't seem to have any effect.

// Custom validation error messages public static $messages = array( 'boolean' => 'The :attribute must be a valid boolean value.', );

Any thoughts?

Last updated 3 years ago.
0

OK; when I actually add my custom error messages to the Validator::make() call it works:

$validation = Validator::make( $member_properties, Member::$rules, Member::$messages );

So I'll go that route.

Last updated 3 years ago.
0

I also had this problem, fixed it by updating lang/en/validation.php with:

"boolean" => "The :attribute field must be a valid boolean value.",
Last updated 3 years ago.
0

You should create a new pull request for the validation rule.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

aGervais agervais Joined 17 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.