Support the ongoing development of Laravel.io →
Forms Validation

Hi all, i have an app that provides registration users and edit information account.

In registration phase the email is required but when a user try to edit his information account. i don't want give the possibility to edit the email.

How can i make this possibile using the same validation rules in model User?

thanks

Last updated 3 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 3 years ago.
0

ok thanks

Last updated 3 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.

© 2025 Laravel.io - All rights reserved.