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

add isTrue and isFalse checks on boolean #910

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

tomdohnal
Copy link
Contributor

This resolves #904 :)

src/boolean.js Outdated
isFalse(message = locale.isFalse) {
return this.test({
message,
name: 'isFalse',
Copy link
Owner

Choose a reason for hiding this comment

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

the exclusive flag doesn't do anything unless there is another test with the same name. So you want to name both of this something like is-value, then bool().isFalse().isTrue() will only use the last isTrue, instead of creating an unmatchable schema

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. I updated it according to your suggestion

src/locale.js Outdated
export let boolean = {};
export let boolean = {
isTrue: '${path} field must be true',
isFalse: '${path} field must be false',
Copy link
Owner

Choose a reason for hiding this comment

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

you can get away with one message here: isValue: '${path} field must be ${expected}', by adding the expected value to the test params`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, done : )

@lucasff
Copy link

lucasff commented Nov 30, 2020

I think this PR is good to go. Let's merge it?

@jquense jquense merged commit 630a641 into jquense:master Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a first-class support for checking truthiness of booleans
3 participants