As valid, with laravel, that a field is only numeric?

2

I have tried with what appears in the documentation of laravel, but it does not help me

this is my code:

'cedula' =>  'numeric|required|unique:personas|min:6|max:8',

This way, if I put letters, it says: "cedula must be numeric."

and if I put numbers tells me that it should not be greater than 8, when I even place 3 numbers.

I do not understand why: /

    
asked by Pablo Contreras 18.11.2016 в 01:41
source

3 answers

3

Based on the comments, this should be the syntax of min and max to work with minimum values of 100000 and maximum of 99999999:

'cedula' =>  'numeric|required|unique:personas|min:100000|max:99999999',
    
answered by 18.11.2016 / 03:27
source
1

ANOTHER ALTERNATIVE would be that you would use

'cedula' =>  'numeric|required|unique:personas|digits_between:6,8',

It works to validate the number of numbers inserted in a field.

In this case it says that the field must contain between 6 and 8 digits.

    
answered by 07.05.2018 в 21:35
0

according to the documentation:

  

between: min, max The field under validation must have a size between   the given min and max. Strings, numerics, and files are evaluated in   the same fashion as the size rule.

then it would be like this:

  

'cedula' = > 'required | numeric | unique: people | integer | between: 6,8',

I think this may work, too: Edited 1:

  

'cedula' = > 'required | numeric | unique: people | integer | min: 000000 | max: 99999999',

note: none of the two solutions was not tested by me, try it and comment if it worked.

    
answered by 18.11.2016 в 03:12