poppinss / indicative

Indicative is a simple yet powerful data validator for Node.js and browsers. It makes it so simple to write async validations on nested set of data.
https://indicative.adonisjs.com/
MIT License
417 stars 52 forks source link

Rule to restrict string to exact length #108

Closed Andreyco closed 7 years ago

Andreyco commented 7 years ago

If I am not mistaken, Laravel provides size:n rule to validate length of array and/or string.

Would be great to include such rule.

Open to PR?

thetutlage commented 7 years ago

Yup, also if you can add same to the raw validations aswell 👍

Andreyco commented 7 years ago

Gosh... totally forgot about this. Still on my list, will contribute later ;)

CodingDive commented 6 years ago

Any news on this? :) Edit: Oh I just saw the max and min rule. Don't need the size rule anymore.

AleksandarSavic95 commented 5 years ago

For anyone coming from Google, You can use Laravel's 'size:N' rule:

For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value. For an array, size corresponds to the count of the array. For files, size corresponds to the file size in kilobytes.

Example: https://stackoverflow.com/a/56183514/2101117