You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, another excellent mafintosh lib. I use mongojs on the daily. You've got a knack for UX.
I've run into an issue (bug?) when evaluating the minLength of any given array being validated. Consider the following:
var validate = validator({
type: 'object',
required: true,
additionalProperties: false,
properties: {
pages : {
type : 'array',
required : true,
minLength : 3,
items : {
type : 'object',
additionalProperties : false,
properties : {
title : {
type : 'string',
required : true
},
url : {
type : 'string',
required : true
}
}
}
}
}
}, {
verbose : true
})
var data = {
pages : [
{ title : 1, url : 'http://someurlhere.com' },
{ title : 2, url : 'http://someotherurlhere.com' }
]
}
var valid = validate(data); // true
if (validate.errors) {
console.log(validate.errors)
}
I would expect this to throw since I've declared minLength: 3 for the pages array. But it passes even though I'm only sending two items through on the data object.
Is this the expected behaviour?
Additionally, when passing an empty array, the data validates just fine when I'm expecting an empty array to throw. Is this also the expected behaviour?
var data = {
pages : []
}
var valid = validate(data); // true
Thanks for any light you can shed on this!
The text was updated successfully, but these errors were encountered:
varvalidator=require('is-my-json-valid')varvalidate=validator({type: 'array',items: {type: 'string'},minLength: 3})console.log(`this should be false: ${validate(['a','b'])}`)
Hi there, another excellent mafintosh lib. I use
mongojs
on the daily. You've got a knack for UX.I've run into an issue (bug?) when evaluating the
minLength
of any given array being validated. Consider the following:I would expect this to throw since I've declared
minLength: 3
for thepages
array. But it passes even though I'm only sending two items through on thedata
object.Is this the expected behaviour?
Additionally, when passing an empty array, the data validates just fine when I'm expecting an empty array to throw. Is this also the expected behaviour?
Thanks for any light you can shed on this!
The text was updated successfully, but these errors were encountered: