-
-
Notifications
You must be signed in to change notification settings - Fork 623
"optional" with parameters "checkFalsy", "nullable" seems not work again. #608
Copy link
Copy link
Closed
Labels
Description
Hello!
In data below, fields external_id and external_system_id may be null or not present or contain proper value. So, i use checkFalsy: true and nullable: true but that not work and validation returns error:
{
: "errors":
: [
: : {
: : : "location":"body",
: : : "param":"external_id",
: : : "value":null,
: : : "msg":"Invalid value"
: : },
: : {
: : : "location":"body",
: : : "param":"external_system_id",
: : : "value":null,
: : : "msg":"Invalid value"
: : }
: ]
}
Data:
{
"id":"23efb1b1-c195-472c-b43e-f2c4ed26fa6e",
"external_id":null,
"external_system_id":null,
"name":"test"
}
{
"id":"23efb1b1-c195-472c-b43e-f2c4ed26fa6e",
"name":"test"
}
Rule (typescript):
export const checkSchema: ValidationSchema = {
id: {
in: ['body'],
isUUID: true
},
external_id: {
optional: {
checkFalsy: true,
nullable: true
},
in: ['body'],
isString: true
},
external_system_id: {
optional: {
checkFalsy: true,
},
in: ['body'],
isUUID: true
},
name: {
in: ['body'],
isString: true,
isLength: {
options: {
min: 1,
max: 100
},
errorMessage: 'Accepted length 1-100'
}
}
};
Reactions are currently unavailable