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

Construct a validator with a list of rules the same size of your input.

for($i = 0; $i <= count(porcentaje); $i++){

  $rules['porcentaje.' . $i] = 'required|numeric|between:0,100';

}

$validator = Validator::make($porcentaje, $rules);
Last updated 2 years ago.
0

Not sure if I understand the question correctly.

To show custom message, http://laravel.com/docs/validation#custom-error-messages

$customMessages = array(
   'customer_name.required' => 'Hey, you forgot to put your name! '
);

$rules = array(
   'customer_name' => 'required'
);

$validation = Validator::make($data, $rules, $customMessages);

// If your html input is an array, hence <input type="text" name="customer[name]" />,
// you will do this. 

$rules = array(
    'customer.name' => 'required',
);

$customMessages = array(
    'customer.name.required' => 'Hey you forgot to put in your name !!',
);

$validation = Validator::make($data, $rules, $customMessages); 
Last updated 2 years ago.
0

To add custom message for each of you fields its the same thing :

for($i = 0; $i <= count(porcentaje); $i++){

  $rules['porcentaje.' . $i] = 'required|numeric|between:0,100';
  $messages['porcentaje.' . $i] = 'porcentaje invalid';

}

$validator = Validator::make($porcentaje, $rules, $messages);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

montes2012 montes2012 Joined 11 Feb 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.