not recognizing error messages specified for a custom validation in laravel 4.2 -
i made custom validation in laravel 4.2 , put in app/start/global.php , code there this
validator::extend('captcha', function($attribute, $value, $parameters) { $captcha = $_session["captcha"]; return $value == $captcha; }); validator::extend('csy', function($attribute, $value, $parameters) { $appnd = "sy " . $value ."-". ($value + 1); $chksy = db::table('dbo_schoolyear') ->where('schoolyear' , '=' , $appnd) ->count(); if($chksy) { return false; } else { return true; } });
then in controller here code
$rules = array( 'nsy' => 'required|integer|min:2005|csy' ); $messages = array( 'nsy.required' => 'please enter starting year.', 'nsy.integer' => 'starting year can contain integer values', 'nsy.min' => 'school year minimum 2005', 'nsy.csy' => 'school year exists' );
the validation works message declared in messages array not being recognized. dont know why. error outputs validation.c_sy ideas on doing wrong?
it's camelcase issue: csy
being interpreted c_sy
.
simply change csy
csy
.
Comments
Post a Comment