Saturday, 15 January 2011

php - Laravel 4 validators - Validate one of two fields -



php - Laravel 4 validators - Validate one of two fields -

is there generic laravel validator alternative allows me illustration below?

example: have 2 text boxes, @ to the lowest degree 1 of them must filled. 1 has compulsorily filled, not required 2 filled.

looks laravel has built-in rules: required_without , required_without_all.

required_without:foo,bar,...

required_without:foo,bar,... field under validation must nowadays when of other specified fields not present.

required_without_all:foo,bar,...

required_without_all:foo,bar,... field under validation must nowadays when of other specified fields not present.

so in validation do:

$validator = validator::make( [ 'textbox1' => input::get('textbox1'), 'textbox2' => input::get('textbox2'), ], [ 'textbox1' => 'required_without:textbox2', 'textbox2' => 'required_without:textbox1', ] );

php laravel laravel-4

No comments:

Post a Comment