This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 336
Better support for arrays #1
Labels
Milestone
Comments
This would be particularly useful for me at the moment. I am trying to figure out the best way to validate all child objects inside an array. I have an object that looks something like this: {
jobs:[
{
key: value
},
{
key: value,
anotherKey: 'anotherValue'
},
{
invalidKey: false
}
]
} Just brainstorming syntax I was figuring something like this... jobs: {
presence: true,
length: {
minimum: 1,
maximum: 5
}
// maybe this only supports arrays?
each: {
key: {
presence: {
message: 'is required!'
}
},
anotherKey: {
datetime: true
}
}
} Also clean attributes would have to be updated to toss Thoughts? |
jpbufe3
pushed a commit
to jpbufe3/validate.js
that referenced
this issue
Apr 3, 2016
Added a new validator, `each`, which applies a validation function provided in the options to each of the objects in the array being validated. Closes ansman#1
jpbufe3
pushed a commit
to jpbufe3/validate.js
that referenced
this issue
Apr 26, 2016
Added a new validator, `each`, which applies a validation function provided in the options to each of the objects in the array being validated. Closes ansman#1
jpbufe3
added a commit
to jpbufe3/validate.js
that referenced
this issue
Apr 26, 2016
Added a new validator, `each`, which applies a validation function provided in the options to each of the objects in the array being validated. Closes ansman#1
Closed
Any idea when this is going out? Must say this is much needed feature. |
You could do something like this: https://stackoverflow.com/a/51406790/2847302 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This would be very useful for validating input from checkbox for example where you can choose more than one alternative.
The length validator already works with arrays (though the default message is for strings) but perhaps inclusion should (optionally?) support arrays saying that each item in the array must be in the inclusion list.
Another useful thing to validate would be uniqueness of the items in the array to make sure you haven't picked the same item twice.
The text was updated successfully, but these errors were encountered: