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

Fixed logic in "42" tests #2203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ For instance this will work:
let schema = number().test(
'is-42',
"this isn't the number i want",
(value) => value != 42,
(value) => value === 42,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(value) => value === 42,
(value) => value == null || value === 42,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying you want the test to pass if the value is null?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its undefined or null. that is handled by required, defined etc

);

schema.validateSync(23); // throws ValidationError
Expand All @@ -789,7 +789,7 @@ however this will not:

```js
let schema = number().test('is-42', "this isn't the number i want", (value) =>
Promise.resolve(value != 42),
Promise.resolve(value === 42),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Promise.resolve(value === 42),
Promise.resolve(value == null || value === 42,),

);

schema.validateSync(42); // throws Error
Expand Down