Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strings cannot be null even not required @4.9.0 #113

Open
mvcds opened this issue Jul 21, 2019 · 0 comments
Open

Strings cannot be null even not required @4.9.0 #113

mvcds opened this issue Jul 21, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mvcds
Copy link
Owner

mvcds commented Jul 21, 2019

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 mvcds added the bug Something isn't working label Jul 21, 2019
@mvcds mvcds added this to the A serious tool milestone Jul 21, 2019
@mvcds mvcds self-assigned this Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant