Framework: Validation 'required|max:255|numeric showing max error bug

Created on 13 Mar 2014  Â·  9Comments  Â·  Source: laravel/framework

When I apply
Validation for 'required|max:255|numeric' or 'required|max:255|integer', I keep getting Max validation error. Even I only have '1234556' input.
But it will work when I remove the numeric or integer validation rules.

Laravel version: 4.1.22

Most helpful comment

If you want to limit the number of digits you can use:
'required|numeric|digits:10'
or
'required|numeric|digits_between:10,15'

All 9 comments

1234556 > 255 => validation error. Laravel is clever and knows from the numeric rule what size check it needs to perform.

Yeah, that number is bigger than 255.

so the max:255 is not the no. of character? I was thinking it is to set the field for varchar(255).

I think you might want the digits rule.—
Sent from Mailbox for iPhone

On Thu, Mar 13, 2014 at 8:27 PM, shiroamada [email protected]
wrote:

so the max:255 is not the no. of character?

Reply to this email directly or view it on GitHub:
https://github.com/laravel/framework/issues/3874#issuecomment-37606503

Okay, thanks taylor!

If you want to limit the number of digits you can use:
'required|numeric|digits:10'
or
'required|numeric|digits_between:10,15'

Thanks tamanti
I have same problem but after this problem was solved..

In my case this works as well
'required|string|min:255',

But how to validate that string is numeric but has less than 255 digits, also it's not required.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shopblocks picture shopblocks  Â·  3Comments

iivanov2 picture iivanov2  Â·  3Comments

gabriellimo picture gabriellimo  Â·  3Comments

RomainSauvaire picture RomainSauvaire  Â·  3Comments

Anahkiasen picture Anahkiasen  Â·  3Comments