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

use computed.bool instead of directly messages length #670

Merged

Conversation

panthony
Copy link
Contributor

because computed.or does not coalesce to bool, we otherwise end up with the number of errors instead of true in isInvalid and isInvalidAndTouched

Signed-off-by: Anthony Pessy anthony.pessy@gmail.com

@miguelcobain
Copy link
Collaborator

Can you convert these to integration tests, please?

because `computed.or` does not coalesce to bool, we otherwise end up with the number of errors instead of true in `isInvalid` and `isInvalidAndTouched`
@panthony panthony force-pushed the fix/paper-input-bool-state branch from 811d6b3 to d0f5d74 Compare March 16, 2017 17:10
@miguelcobain
Copy link
Collaborator

Can we promote

hasErrorMessages: computed.bool('validationErrorMessages.length'),

to the Mixin

and then paper-input would just override isInvalid to account for native invalids?

@panthony
Copy link
Contributor Author

@miguelcobain In ValidationMixin we would have:

  hasErrorMessages: computed.bool('validationErrorMessages.length'),

  isInvalid: computed.bool('validationErrorMessages.length'),

And in paper-input:

  isInvalid: computed.or('hasErrorMessages', 'isNativeInvalid'),

Is that correct?

@miguelcobain
Copy link
Collaborator

miguelcobain commented Mar 16, 2017

I was thinking, for consistency

// validation-mixin.js
hasErrorMessages: computed.bool('validationErrorMessages.length'),
isInvalid: computed.reads('hasErrorMessages'),

and

// override validation mixin `isInvalid` to account for the native input validity
isInvalid: computed.or('hasErrorMessages', 'isNativeInvalid'),

Please include the comment to make it clearer.

@panthony panthony force-pushed the fix/paper-input-bool-state branch from 4dc306e to 6f47cfc Compare March 16, 2017 17:33
@miguelcobain
Copy link
Collaborator

Thanks!

@miguelcobain miguelcobain merged commit 72999f8 into adopted-ember-addons:master Mar 16, 2017
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.

2 participants