hubi icon indicating copy to clipboard operation
hubi copied to clipboard

Strings cannot be null even not required @4.9.0

Open mvcds opened this issue 5 years ago • 0 comments

Setting a string as non-required don't allow to use nulls as its value

Enviroment

How to reproduce

name: Foo
attributes:
  - name: optionalString
    required: false
    default: null

Expectations

Expected Behaviour

let success = false
try {
	Joi.attempt({ optionalString: null }, Foo.SCHEMA);
	success = true
} catch(e) {
}

assert.ok(success, 'optionalString should be possible to be set to null')

In the code above the assert.ok should not fail

Actual Behaviour

It fails with the message "[1] "optionalString" must be a string"

mvcds avatar Jul 21 '19 12:07 mvcds