Try something like this:
$rules = [
// Validation rules
"firstname" => "required",
"lastname" => "required",
"phone" => "required"
];
$messages = [
// Custom error messages
"firstname.required" => "Please enter your first name.",
"lastname.required" => "Please enter your last namer.",
"phone.required" => "Please enter a phone number where you can be reached."
];
if(Input::get('action') == "create") { // Example, check if the user is beeing created
// Add new rules
$rules["email"] = "required|email";
$messages["email.required"] = "Please enter an email address.";
$messages["email.email"] = "Please enter a valid email address.";
}
$validator = Validator::make(Input::all(), $rules, $messages);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community