-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Exact Array #1
Comments
There should be a simpler way to do it, but for now, try this: var YoungDuck = schema({ age: 1 });
var OldDuck = schema({ age: 7 });
var Animals = schema({
ducks: schema({
0: YoungDuck,
1: OldDuck,
'*': null, // or length : 2
constructor: Function.reference(Array)
}),
}) The only modification I made to your example is that I added the Also consider using the deep equality pattern if applicable in your case ( I think that the array handling of js-schema is still very immature, and it would be nice to solve its issues in a more general way. But for now, your |
By the way, you don't need to nest var YoungDuck = schema({ age: 1 });
var OldDuck = schema({ age: 7 });
var Animals = schema({
ducks: {
0: YoungDuck,
1: OldDuck,
'*': null, // or length : 2
constructor: Function.reference(Array)
}
}) |
First of all thanks for this awesome library!
This can be also a documentation issue because I could not figure out how to do it. I'd like to have a way to validate that I have some exact array in my object.
For example
Closest thing I managed to create is this:
but this of course validates this too
Could it be possible to have something like this?
The text was updated successfully, but these errors were encountered: