clock  Mon - Sun 8.00 AM - 8.00 PM
fb
instagram
play store
pinterest

Form Input Validation Rules in Laravel

writter  Sumit Dey Sarkar
Date  25 Mar 2023
Language  Laravel
Form Input Validation Rules in Laravel

Form Input Validation Rules in Laravel

In this tutorial we will see form input validation rules in laravel.

 

Form input validation rules in laravel

Laravel provides many type of validation rules by which you can validate user input.

Some of the commonly used validation rules in Laravel are:

 

  1. required: The field is required.
  2. filled: The field is required and not null.
  3. email: The field must be a valid email address.
  4. numeric: The field must be a numeric value.
  5. integer: The field must be an integer value.
  6. string: The field must be a string.
  7. array: The field must be an array.
  8. boolean: The field must be a boolean value.
  9. date: The field must be a valid date.
  10. date_format:format: The field must match the given date format.
  11. after:date: The field must be after the given date.
  12. before:date: The field must be before the given date.
  13. size:value: The field must be the given size.
  14. min:value: The field must be at least the given value.
  15. max:value: The field must not exceed the given value.
  16. unique:table,column,except,idColumn: The field must be unique in the specified table and column, except for the specified ID column (optional).
  17. exists:table,column: The field value must exist in the specified table and column.
  18. regex:pattern: The field must match the given regular expression pattern.
  19. alpha: The field must contain only letters (a-zA-Z).
  20. alpha_dash: The field may contain letters, numbers, dashes, and underscores.
  21. alpha_num: The field may contain only letters and numbers.
  22. distinct: The field values must be unique.
  23. in:foo,bar,...: The field value must be one of the specified values.
  24. not_in:foo,bar,...: The field value must not be one of the specified values.
  25. confirmed: The field must have a matching confirmation field (e.g. password and password_confirmation).
  26. gt:field: The field must be greater than the specified field.
  27. gte:field: The field must be greater than or equal to the specified field.
  28. lt:field: The field must be less than the specified field.
  29. lte:field: The field must be less than or equal to the specified field.
  30. json: The field must be a valid JSON string.
  31. mimetypes:text/plain,...: The field must be one of the specified MIME types.
  32. file: The field must be a valid file.
  33. image: The field must be a valid image file.
  34. timezone: The field must be a valid timezone identifier.
  35. url: The field must be a valid URL.
  36. active_url: The field must be a valid URL with a DNS record.
  37. regex:/^[a-zA-Z0-9\s]+$/: The field must match the given regular expression pattern.
  38. digits:value: The field must be numeric and have an exact length of value.
  39. digits_between:min,max: The field must be numeric and have a length between min and max.
  40. size:value: The field must have a file size equal to value (in kilobytes).
  41. dimensions:min_width=min, max_width=max,min_height=min, max_height=max: The field must have dimensions within the specified range.
  42. nullable: The field may be null. This rule is often used in combination with other rules to allow for optional input.
  43. sometimes: The field will only be validated if it is present in the input array. This rule is often used when you have optional input fields that should be validated if they are present.
  44. prohibited: The field is prohibited from being included in the input data. This rule can be useful if you want to explicitly disallow certain fields from being submitted.
  45. prohibited_if:anotherfield,value: The field is prohibited from being included in the input data if anotherfield has the given value.
  46. required_if:anotherfield,value: The field is required if anotherfield has the given value.
  47. required_unless:anotherfield,value: The field is required unless anotherfield has the given value.
  48. required_with:foo,bar,...: The field is required if any of the specified fields are present in the input data.
  49. required_with_all:foo,bar,...: The field is required if all of the specified fields are present in the input data.
  50. required_without:foo,bar,...: The field is required if none of the specified fields are present in the input data.
  51. required_without_all:foo,bar,...: The field is required if none of the specified fields are present in the input data.
  52. starts_with:value1,value2,...: The field value must start with one of the specified values.
  53. ends_with:value1,value2,...: The field value must end with one of the specified values.
  54. nullable_if:anotherfield,value: The field may be null if anotherfield has the given value.
  55. nullable_unless:anotherfield,value: The field may be null unless anotherfield has the given value.
  56. after:date: The field must be a date that comes after the given date.
  57. after_or_equal:date: The field must be a date that comes after or is equal to the given date.
  58. before:date: The field must be a date that comes before the given date.
  59. before_or_equal:date: The field must be a date that comes before or is equal to the given date.
  60. accepted: The field must be accepted (e.g. a checkbox that must be checked).
Comments 0

Leave a comment

Coursera, Codeacademy, Udacity, W3Schools, Udemy, Alison, TheNewBoston, edX, P.S.Codewars,Freecodecamp, Managing technical debt blog, Scrimba, Codepen, Codepen/challenges, The Odin Project, htmlreference.​io, cssreference.​io, Frontend Mentor, Dev Challenges, MDN, Code Mentor, Coding Dojo, CSS Battle, Codier, Ace Frontend, Can I Use, CSS Tricks, 30 Seconds of Code,tutorialspoint, Neumorphism, Shaddows Brumm, Fancy Border Radius, Glow Generator, Clothoid Corners, Glassmorphism, Clipy, CSS Filters, Base64 Image, Quantity Queries, Animations, Cubic-Bezier, Keyframes, Wait Animate, Transition.Style, graphic design, web design, website design, website builder, web developer, web designer, webdesign, ecommerce website, web design company, website creator, website designer, responsive web design, web development company, best website design, web design software, web page design, build a website, web developer salary, design website, web design courses, how to design a website, web design inspiration, website layout, web designer salary, web application development, ecommerce website design, web agency, software development company, web design tutorial, web programming, design company, website design templates, what is web designing, web developer jobs, website developer, web design agency, freelance web developer, web design services, freelance web designer, graphic design websites, web solutions, ecommerce website development, free website design, web development courses, webdev, web developers, web development tools, website design services, developpeur web, web design london, website design ideas, web designing and programming, design a website, web design and development, web dev, web development services, homepage design, best designed websites, cheap website design, learn web design, web design templates, web design tools, web design jobs, website design inspiration, web design india, flash website, website developers, designer websites, website services, website design cost, good website design, site design, simple website design, cool website designs, modern website design, graphic designer websites, webcode, best web design software, website making, free web design software, mobile website design, learn web development, front end web developer, how to become a web developer, web developer portfolio, web development company in india, python web development, web development tutorial, website company, website design and development, web company, webdesigning, professional website design, affordable web design, best web design company, creative web design, top website designs, website design pricing, web developer tools, how to develop a website