This repository was archived by the owner on Jun 19, 2023. It is now read-only.
Is there a way to set onInvalid throw at the document level? #68
Open
Description
Is it possible to throw an error when trying to save an object with not defined attributes?
For example: if I define a schema only with firstName
, then I try to save lastName
, is there a way to cause it to raise an error? Currently, it is silently ignoring the any not defined value, but I would rather receive an error.
I tried (random attempt) to use onInvalid: 'throw'
, but it didn't work.
Object.defineProperties(Model.prototype, {
[DynamoDbTable]: {
value: 'table',
},
[DynamoDbSchema]: {
onInvalid: 'throw',
value: {
hash: { type: 'String', keyType: 'Hash' },
range: { type: 'String', keyType: 'Range' },
firstName: { type: 'String' },
data: {
type: 'Document',
members: dataSchema,
onInvalid: 'throw'
}
}
}
})