I am using Laravel 4 in which I have a field email or pincode that you can tell.Therefore, when using the Laravel validator, I want to check if it is an email or not, only if the value is filled otherwise, it will ignore it.
You can use the sometimes rule in the rule list:
$v = Validator::make($data, array( 'email' => 'sometimes|required|email', ));
http://laravel.com/docs/validation#conditionally-adding-rules
email. required , , , , email.
email
required
.
...
$validator = Validator::make( array('pincode' => 'email'), ... other field => rules );
Laravel will not know about the value before sending your data. So you need to use javascript to check email syntax checking