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

Superflous keys are ignored #351

@White-waluigi

Description

@White-waluigi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions