Support the ongoing development of Laravel.io →
Forms Validation
Last updated 2 years ago.
0

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);
Last updated 2 years ago.
0

ok thanks

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ocraton ocraton Joined 18 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.