Skip to content
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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