php - Validating dates in Laravel (4.2) -



php - Validating dates in Laravel (4.2) -

i'm having problem validating dates in laravel (4.2)

$input = array('date_field' => '23/12/2'); $validation_rules = array('date_field' => 'required|date_format:d/m/y'); $validation = validator::make($input, $validation_rules); echo ($validation->fails()) ? 'fail' : 'pass';

with sample (though incorrect) date beingness passed 23/12/2, validator still returns pass, technically should fail.

i'm trying forcefulness input field format matches dd/mm/yy uk date format.

thanks!

you may utilize regex: ensure format in add-on date_format, example:

$validation_rules = [ 'date_field' => [ 'required', 'date_format:m/d/y', 'regex:#[0-9]{2}\/[0-9]{2}\/[0-9]{2}#' ] ];

but '23/12/2' not valid , supposed failed confused why passed, anyway!

php laravel

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -