Closed technoknol closed 12 months ago
Hey @technoknol! 👋🏻
This is the expected behavior. The validated data will not have the properties you have not defined in your schema.
const data = {
username: 'romain.lanz',
avatar_url: 'http',
wrong: true
}
const validatedData = await validator.validate({
schema: schema.create({
profile: schema.object().members({
username: schema.string(),
avatar_url: schema.string()
}),
}),
data,
});
Here, validatedData
will not have the wrong
property.
Package version
5.9.0
Node.js and npm version
node: 16.15.0 , npm: 8.5.5
Sample Code (to reproduce the issue)
Schema
Request Payload
This validation passes and doesn't throw an error even if
asdfasd
is neither defined noranyMembers
is used.