| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
* New validator: forEach and forEachSingle * Add validator specification about return value.
|
Hey guys, when can we expect this to be released? 😃 |
Sorry, something went wrong.
|
Is there any update on this? |
Sorry, something went wrong.
|
+1 |
Sorry, something went wrong.
|
I think that instead return a object like: {
'ary[1].name': 'Cant be blank',
'ary[1].somethikng': 'Cant be blank'
}
should be: {
ary: [
{ name: 'Cant be blank', something: 'Cant be blank' }
]
}
or: {
ary: {
1: {
name: 'Cant be blank',
something: 'Cant be blank'
}
}
}
What you think? |
Sorry, something went wrong.
|
+1 |
Sorry, something went wrong.
|
At first glance, without writing a custom formatter, it looks like the minimum we can do is the following. length: {
minimum: 1
}
which only checks length and a string would give us a false positive, when we're looking for an array. Is there a widely accepted array formatter pattern that people are using in the meantime? Something that could validate this kind of pattern: {
"id": "123",
"notes": [
{
"date": 2015-10-05T12:00:00,
"comments": "monty python"
},
{
"date": 2015-10-06T12:00:00,
"comments": "something else entirely"
}
]
}
definitely looking forward to this PR! thanks :) edit: example custom validator to validate all values in an array for example above custom validator: validate.validators.arrayValidator = function(value, options) {
if (!Array.isArray(value))
return 'must be an array';
value.forEach(function(obj) {
validate(obj, options);
});
};
schema: notes: {
length: {
minimum: 1
},
arrayValidator: {
date: {
datetime: true
},
comments: {
length: {
minimum: 10
}
}
},
presence: true
|
Sorry, something went wrong.
|
I'm so sorry. This PR slipped through the cracks it seems, it looks like a good first implementation. If you add some tests I'll try to get it merged ASAP. |
Sorry, something went wrong.
|
@ansman Any update on when this will be released? Thank you. |
Sorry, something went wrong.
|
+1 |
Sorry, something went wrong.
|
This would be pretty cool |
Sorry, something went wrong.
|
Its some way how works with var constraints = {} like with array I have trouble, when is in {} some element which not exists, code does not work Original: Will be like: // dont care about "exists()" // dont care about "exists()" |
Sorry, something went wrong.
|
@nishidayuya resolve merge conflicts when you have time :D |
Sorry, something went wrong.
|
any update on when this will be released? |
Sorry, something went wrong.
|
+1 when can we expect this? |
Sorry, something went wrong.
|
I worked around this for now, but it would be great to have this baked in. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I implemented forEach validator and forEachSingle validator. We can specify any constraints for each array element.
Why [WIP]?
This pull-request is WIP (work in progress), because I want you to check following:
After you accept them, I will create tests, git push it and remove [WIP] mark.
forEach validator
This validator checks object properties in array element.
Sample:
This is following requests implementation:
I think this validator name is forEach and it is better than each. I thought following:
forEachSingle validator
This validator checks object in array element like validateSingle function.
Sample: