Laravel validate float number lenght (not value of float)

Viewed 936

I want to validate the length of a float number, not the value itself I am talking about the length. The length should be max 9.

Examples:

0              OK
0.00           OK
5              OK
20             OK
100            OK
4000           OK
100000         OK   
100000000      OK
100000000,00   OK
1000000000     NO its 10 digits long

Please note, if the number contains decimals they should not count!

This is what I have tried so far:

  1. max:9 this always results in validating the value instead of the length of the number
  2. digits_between:0,9 always returns in The price old must be between 0 and 9 digits. even tho the value is 12.51 which I don't get
  3. size will not work for me because it's a fixed length

Any ideas on how to solve this? I don't get why digits_between:0,9 is not working even though the documentation is saying length instead of value (Quote: The field under validation must have a length between the given min and max.).

I am using Laravel 8.

Kind regards

1 Answers

So you are basically looking for this.

max:999999999
Related