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

If you just want to change the text, look in lang/en/validation.php,

or take a look at this tutorial on creating custom validation rules.

Last updated 2 years ago.
0

You are looking for:

'The field has to be :min chars long'
Last updated 2 years ago.
0

Reached said:

You are looking for:

'The field has to be :min chars long'

Yep but this applies to all min-validations .-(

Just imagine several fields with min-rules.

Last updated 2 years ago.
0

Yea, but you need to look into custom rules as pogachar mentioned.

Specifying the name of the input field that you want to make a custom message for, enables you to use the different attributes for them.

An example here (lang/en/validation.php):

'custom' => array(
	'activity_title' => array(
		'required' => 'Du skal vælge en aktivitet.',
		'min' => 'Du skal minimum indtaste :min karakterer.',
                  ),
),
Last updated 2 years ago.
0

For other developers facing the same problem, You have two options , One is to use the method described by @Reached above , Or you can declare everything in your controller as follows

       $messsages = array(
		'email.required'=>'You cant leave Email field empty',
		'name.required'=>'You cant leave name field empty',
                'name.min'=>'The field has to be :min chars long',
	);

	$rules = array(
		'email'=>'required|unique:content',
		'name'=>'required|min:3',
	);

	$validator = Validator::make(Input::all(), $rules,$messsages);

I hope this help.

Last updated 9 years ago.
0

surely it makes sense for you to tell users the same message i.e the field has to be :min char long? why would you not do this for every field?

0

Hi, I would like to suggest three way to change laravel default validation example in Laravel 5.5 : https://hdtuto.com/article/php-laravel-set-custom-validation-error-messages-example

I hope above link will help you lots...

Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Sharping sharping Joined 28 Jun 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.