Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Superflous keys are ignored #351

Open
White-waluigi opened this issue Aug 10, 2021 · 0 comments
Open

Superflous keys are ignored #351

White-waluigi opened this issue Aug 10, 2021 · 0 comments

Comments

@White-waluigi
Copy link

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)?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant