DEV Community

Morcos Gad
Morcos Gad

Posted on

4

New Feature Laravel min_digits and max_digits Validation

In the new version 9.26 we have the feature min_digits and max_digits validation

According to the size rule, the number of digits in a digital input cannot be traditionally validated using min and max.

Currently, we have digits to validate the exact length of a number, and digits_between to validate the length within two bounds.

However, as far as I can see, there is still no way to verify that a number has a minimum or maximum number of digits, just both.

This PR offers two validation rules - min_digits and max_digits for this usage

https://github.com/laravel/framework/pull/43797

Validator::validate([
    'number' => 1000,
], [
    'number' => [
        // Passes as `1000` has 4 digits
        'min_digits:3', 'max_digits:5',
        // Fails as `1000` is greater than 5
        'min:3', 'max:5',
    ],
])
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.

Source :- https://laravel-news.com/laravel-9-26-0
Source :- https://www.youtube.com/watch?v=ZCYqn0Y6qc0

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
thetnaingtun3 profile image
Thet Naing Tun

Great. Thanks!

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay