-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
rule dependencies #279
Comments
Some ideas:
|
This was previously supported because all rules of the object were re-evaluated after any property of that object changed. Perhaps if the code for |
I came up with #280 and aurelia/validatejs#117. I'll publish a GistRun to see it in action! |
Of course, all that fuss could be avoided if we call |
I'm hesitant to put UI stuff in the fluent rule api because it's intended to be used server-side. Would it be better to create some sort of binding behavior that you can use to express UI dependencies for rule validation? <input type="password" value.bind="password & validate">
<input type="password" value.bind="passwordConfirm & validate & dependsOn:'password'"> Today you could do something like this: <div change.delegate="controller.validate()">
<input type="password" value.bind="password & validate">
<input type="password" value.bind="passwordConfirm & validate">
</div> Or this: <input type="password" value.bind="password & validate"
change.delegate="controller.validate()">
<input type="password" value.bind="passwordConfirm & validate"> Or this: <input type="password" value.bind="password & validate"
change.delegate="controller.validate({ object: $this, propertyName: 'passwordConfirm' })">
<input type="password" value.bind="passwordConfirm & validate"> Not saying we cannot add |
It seems to me that any "rule that depends on another rule" should be defined as a single rule using But using My use case: I am validating at the object level, thus must manually call Each object contains object rules (defined by Further, I am using neither the A ValidationRenderer could be useful for me in this scenario, but it is not, for the following reasons:
Thus I propose the following: Add a parameter Change the type of I think this fits fairly nicely into the existing paradigm. This will help with #351 |
Alternative suggestion, perhaps even better: Add a parameter to |
@jdanyow, I tried to use aurelia-validation on the server side in a nodejs application but it looks like ValidationRules has still dependencies on Element (lib.d.ts aka DOM dependency), which makes it fail. I noticed that the documentation page on "Server Side Validation"(http://aurelia.io/hub.html#/doc/article/aurelia/validation/latest/validation-basics/13) isn't ready yet because I guess it is still work in progress. I've had a great success using aurealia-dependency-injection on the server side without any issues. I'm about to wrap up part 7 of my tutorial in my blog ( http://opensourcedotnetter.blogspot.com/) on Aurelia validation. Please advice if I should wait for a release of aurelia-validation that works on the server side or should I go ahead with using validate-js directly or the deprecated aurelia-validatejs package. Thanks. |
I face the same issue using aurelia-validatejs package (although it is deprecated) as well since it has a dependency on aurelia-validation. I'm going to go ahead and use validatejs directly in nodejs and return the validation errors to the client. |
Comment from @dkent600 here: #351 (comment) has gist with a couple of scenarios. |
@heruan I'm looking into this, particular at the original use case you provided, and am wondering, is it sufficient, when you set up your rules, to simply require that both |
See also this comment, with a gist, demonstrating a potential solution: #351 (comment) |
I realize this is a pretty old thread, but still open, and I'm hit by this currently. @dkent600, to offer an answer to your question, "is it sufficient..." I think your proposed solution (a custom rule applied to all involved properties) would not work well for the password form of the original question, in terms of the error renderer. Here are steps I'm thinking of:
In summary: although your solution would help get errors on the screen in any case, in a dependent property scenario, errors potentially need to clear when another property changes. As another example, closer to what I'm dealing with today, a user must enter two numbers, a required positive number, and then another number which must be greater than the first. The domain suggests that this "greater than" rule belongs on the second number, but hard to get it to work right. My main point is I think a property dependency mechanism of some sort is still warranted. |
The old library had the ability to make rules dependent on others, i.e. re-evaluate a binding when other bindings are updated; now, this won't work:
Assume
passwordConfirm
must be equal topassword
(supported for example inaurelia-validatejs
with@equality
) thepasswordConfirm & validate
binding should trigger also whenpassword
changes, but the binding behavior doesn't know about the implementation specifics so it won't update/render whenpassword
is changed.The text was updated successfully, but these errors were encountered: