• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.


The Most Popular Additional Laravel Validation Rules

Page history last edited by Adam Mathewz 1 year, 3 months ago

Laravel is a PHP Framework for web artisan that helps build robust applications and APIs. Validation is the most important aspect while you design an application. It refers to the validation of incoming data. Base controller class uses a ValidateRequests trait by default that provides a convenient method to validate incoming HTTP requests with a varied range of powerful validation rules. Laravel always checks for errors in the session data and automatically binds them to the view if available. You must note that a $errors variable is still available in all of your views on every request, letting you conveniently assume the $errors variable which is always defined and you can safely use it. 


Handling request validation is a very crucial part of any application. Most developers are familiar with using the validator in the controller. The most common way to handle validation for the incoming request is to use the validator in the controller. There is nothing wrong with adopting this practice, but it is not the best way to do it, and it messes up your controller. The controller should do only one thing, and that is to handle request from the route and return an appropriate response. 


Writing validation logic in the controller will break the Single Responsibility Principle. Requirements do change with time and with every change you class responsibilities change. Having multiple responsibilities in a single class make to trying to manage.


The Laravel Validation System has 60+ available validation rules. If you need something more, you can easily create your own validation rule or use something already available on the Internet. 

Let us now enlist the most used additional Laravel Validation Rules:

  1. StrongPassword checks for “strong” password.

  2. TelephoneNumber validates telephone number.

  3. RecordOwner needs the authenticated user’s id to match the user_id column on a given database record.

  4. MonetaryFigure validates monetary figures like for example $74.53.

  5. DisposableEmail checks for the email address that you cannot dispose.

  6. DoesNotExist validates whether a value is not present in a given database or column.

  7. Decimal validates decimal with an appropriate format.

  8. EncodedImage is that in which value is a base-64-encoded image of a given mime type.

  9. LocationCoordinates has a comma-separated set of latitude and longitude coordinates.

  10. With FileExists, value is a path to an already existing file.

  11. With Equals, value is equal to another given value.

  12. In MacAddress, value is a valid MAC address.

  13. In ISBN, value is a valid ISBN-10 or ISBN-13 number.

  14. EndsWith validates values that end with a given string.

  15. EvenNumber validates values that are in even numbers in which decimals are first converted using intval.

  16. OddNumber validates values that are an odd number where decimals are first converted using intval.

  17. Lowercase includes a value which is a lowercase string.

  18. Uppercase includes value which is an uppercase string.

  19. Titlecase validates value which is a titlecase string.

  20. Domain is where value is a domain, for example, google.com, www.google.com, etc.

  21. CitizenIdentification has value that is a citizen identification number of USA, UK, or France.

  22. WithoutWhitespace validates the value that does not include any whitespace characters.

  23. Colour validates colours that are currently supporting hex codes only.

  24. CountryCodes validates country codes of two or three characters.

  25. Credit Card validates that a whether a given credit card number, date of expiry or CVC is valid.

  26. IP validates an IP address and checks whether public or private. It supports ipv4 & ipv6.

  27. Phone validates phone number format.

  28. Subdomain validates a subdomain that a user has submitted in your application.

  29. TimeZone validates that a given time zone is valid within the system’s DateTime database.

  30. US State validates US States and Canada Provinces.

  31. With the Authorized rule, the user is authorized to perform an ability on an instance of a given model.

  32. CountryCode validates whether that field is a valid ISO3166 country code.

  33. Enum validates value is a part of the given enum class, e.g., myclabs/php-enum.

  34. ModelsExist validates whether all of the values in the input array exist as attributes for the given model class.

  35. Delimited validates whether a string contains delimited values like "john@example.com, david@example.com."

  36. Value can be incremented only.

  37. Value has specific words.

  38. A day has to be a weekday.

Laravel offers many helpful validation rules, but if you wish to define your own validation rules, you can do that too! You can easily set your own validation rules and then use your custom validation rules in your application whenever you need. Hire Laravel developers to take care of all these Laravel rule validation related issues. In the end, this was all about the most popular Laravel validation rules.

Comments (0)

You don't have permission to comment on this page.