ansman/validate.js

Superflous keys are ignored

White-waluigi opened this issue · 0 comments

If the an object to be checked has keys that do not appear in the pattern it is accepted by validate.js

const validate=require('validate.js')



let pat={

	name:{
		presence:true,
		type:'string'
	},
	city:{
		presence:false,
		type:'string'
	},
}


let obj={
	name:'henry',
	city:'paris',
	age:33
}


console.log(validate(obj,pat))
//undefined, it finds nothing wrong

This seems to make the presence setting pretty pointless, since it accepts it no matter if it is present or not or even defined in the pattern.

So Is there a way to limit the validation to only the actual elements in the pattern (superflous elments cause error)?