Replies: 1 comment 14 replies
-
You need to add that public schema = schema.create({
field1: schema.string(),
field2: schema.string.opcional(),
}) {
"field1": "something",
"field2": null // Undefined
}
// or
{
"field1": "something"
} // No need to send the optional field in the body of the request const { field1, field2 } = await request.validate(validator)
// In both cases above, this value will be undefined
console.log(field2) // Undefined |
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. Let's have a case where the end-user wants to update his profile and he wants to remove his phone number (for example). Since it is an update form, all fields are optional. The problem is when I send a null, validation ignores it and
request.validate
function doesn't return the "phone" field that is null in this case.When I try it using Insomnia (or postman) with phone parameter equals NULL, validator gets it as a string and saves it as a string
Does anyone know how to achieve it?
Beta Was this translation helpful? Give feedback.
All reactions