Search code examples
laravelvalidationlaravel-5laravel-validation

Integer or String for a phone number?


I want to know if I have to use a string or an integer for a phone number?

I have tried an integer but I have a problem in my validation.

... table->integer('phone'); ...

In my validation, I must have between 8 and 11 characters.

I have tried this, but it doesn't work:

'phone' => 'required|numeric|between:8,11',

I think the string is better?


Solution

  • I think the validation should be like this

    'phone' => 'required|numeric|min:8|max:11',