aurelia / validation

A validation plugin for Aurelia.
MIT License
132 stars 129 forks source link

computedFrom rules do not get revalidated if a computation property changes #73

Closed MarcScheib closed 8 years ago

MarcScheib commented 9 years ago

Take the following code snippet:

...
.ensure('password')
    .isNotEmpty()
    .hasLengthBetween(8, 16)
    .isStrongPassword()
.ensure('passwordConfirm', (config) => { config.computedFrom(['password']) })
    .isEqualTo(() => { return this.password }, 'the entered password');

Case 1) Writing in the password field turns passwordConfirm to success. Wirting in passwordConfirm then turns it to warning until it is equal to password (success then).

Case 2) Writing in the passwordConfirm field first turns it to warning. Writing in password then leaves passwordConfirm in warning, even if both are equal.

Case 3) Writing in password field. Then typhing in passwordConfirm. Both are success now. Now, change password again (e.g. add two digits). passwordConfirm is still success.

janvanderhaegen commented 9 years ago

Hmmm, I need to see what's going on. We have tests on this, so it's either a timing issue or I've made some weird assumptions in the test. Will definitely check this weekend!

Thank you for reportin!

jods4 commented 8 years ago

Currently computedFrom is not working in a lot of cases, which makes it unusable. I fixed it in the project I'm working on as in PR #150. This change has worked very well for us, in several cases including some tricky ones.

betrayedjinn commented 8 years ago

This seems still not working in 0.6.0 Any progress on this issue?

jods4 commented 8 years ago

@paranoxx My PR #150 has not been merged yet, and probably won't be any time soon because of the ongoing refactoring of this library.

If you need validation with computedFrom in your project today, your best option is to apply the PR yourself.

betrayedjinn commented 8 years ago

Patching this plugin by my own and find a way to share it with my team is not a way we want to go. If aurelia is not able to patch it, i will switch do another validation library or write my own.

jods4 commented 8 years ago

@paranoxx feel free to do as you'd like!

But I can't help but smile at the irony of your post...

On one hand, you already have a github account... Forking this repo is just one click away. Applying the PR is just a few more clicks. Then you can point (bower / jspm / whatever package manager you use) to your fork instead of this feed. All of this would take you 10 minutes to be ready to easily share with your team.

On the other hand you suggest that you want to "write your own". Sure... you'll spend at least several days for something that nobody else but you uses / maintains.

As I said -- your choice!

betrayedjinn commented 8 years ago

You already did a PR and nobody cares.

EisenbergEffect commented 8 years ago

People care. However, we are right in the middle of releasing the Beta 1 of the core framework. We have also announced that major re-factorings on being worked on for this library. So, you will have to be patient while we work through a major release cycle and a big refactoring of this library.

jods4 commented 8 years ago

@paranoxx I know for sure that @EisenbergEffect does care.

But you should know that aurelia-validation is not even beta at this point. I can tell you from my own experience that this package is still very rough and not mature. That's why it's undergoing a deep refactoring.

When using such "alpha" libraries there are caveats that you need to accept, and be ready to do some tweaking.

plwalters commented 8 years ago

Thanks for submitting this / commenting on this. At this time we are closing this because we have completely re-written and are deprecating the previous feature set. If you feel this should be re-opened please feel free to review this blog post and submit either again on this repository, or on the new validatejs bridge repository

Thanks again!