this is code in route
Route::post('form-submit', function(){
//get all inputs
$inputs = Input::all();
//create array of validation rules
$rules = array('username'=>'required|foo|min:4|max:35','email'=>'required|email');
//set custom error messages
$messages = array(
'foo'=>'Field value must be foo'
);
//validate inputs
$validator = Validator::make($inputs,$rules,$messages);
if($validator->passes()){
//inputs valid
echo 'Well';
}else{
//return to form view with errors
return Redirect::to('form')->withErrors($validator);
}
});
but my main question is where the file is extended ... where will this code file where the function is declared "foo"
Validator::extend('foo', function($field,$value,$parameters){
//return true if field value is foo
return $value == 'foo';
});
Route::get('form', function(){
//render app/views/form.blade.php
return View::make('form');
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community