mikeerickson / validatorjs

A data validation library in JavaScript for the browser and Node.js, inspired by Laravel's Validator.
https://www.npmjs.com/package/validatorjs
MIT License
1.77k stars 280 forks source link

Need Help on validating array of boolean #395

Open deepesh0102 opened 3 years ago

deepesh0102 commented 3 years ago

I have an array of boolean.
How to validate. var data = { status_array: [true, false, true, false] }

var rules = { "status_array": "array|in:true,false", }

Please Help How to validate this type of array.

thefallenmerc commented 3 years ago

Try something like this

var rules = { status_array: "array", "status_array.*": "boolean" }

On Thu, 3 Dec 2020, 15:10 Deepesh Kumar, notifications@github.com wrote:

I have an array of boolean. How to validate. var data = { status_array: [true, false, true, false] }

var rules = { "status_array": "array|in:true,false", }

Please Help How to validate this type of array.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/skaterdav85/validatorjs/issues/395, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4YEY3YOZDWFUJVJEXUSULSS5MIBANCNFSM4ULWXU7A .