rule dependencies
See original GitHub issueThe 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:
<input type="password" value.bind="password & validate">
<input type="password" value.bind="passwordConfirm & validate">
Assume passwordConfirm
must be equal to password
(supported for example in aurelia-validatejs
with @equality
) the passwordConfirm & validate
binding should trigger also when password
changes, but the binding behavior doesn’t know about the implementation specifics so it won’t update/render when password
is changed.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (12 by maintainers)
Top Results From Across the Web
Rule Dependencies · NRules/NRules Wiki - GitHub
Rules can declare their dependencies using fluent DSL, and rules engine will dynamically resolve those dependencies at runtime. The benefit of ...
Read more >Dependency Rules - IBM
Dependency rules are applied on the primary scorecard to filter the Performance Evaluations to be selected to evaluate the secondary scorecard.
Read more >The Dependency Rule Points Them The Right Way
This rule says that source code dependencies can only point inwards. Nothing in an inner circle can know anything at all about something...
Read more >The Clean Architecture Dependency Rule - InformIT
Learn how to apply the Dependency Rule to your software architecture to create a more testable system.
Read more >Violating the Dependency rule — Matthias Noback - Blog
The same is true for another rule that I know as Robert Martin's Dependency rule. Transposed to a layered architecture with an Infrastructure, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
It seems to me that any “rule that depends on another rule” should be defined as a single rule using
.satisfies()
, no? I’m not clear what is the use case where this would not be appropriate or possible.But using
satisfies
still presents an issue.My use case:
I am validating at the object level, thus must manually call
ValidationController.validate()
.Each object contains object rules (defined by
ensureObject().satisfies()
). These object rules do not depend on other rules, but they do relate to a set of properties on the object. However, unlike withensure().satisfies()
it is not possible to associateensureObject().satisfies()
with a property name, much less with multiple property names.Further, I am using neither the
validate
binding nor aValidationRenderer
. Again, I am manually callingValidationController.validate()
, and manually rendering the error information whenvalidate
completes.A ValidationRenderer could be useful for me in this scenario, but it is not, for the following reasons:
validate
binding, it does not provide the element(s) with which a property is associated.ensureObject().satisfies()
Thus I propose the following:
Add a parameter
propertyNames
toensureObject().satisfies(instance)
, like this:ensureObject().satisfies(instance, propertyNames?: string[])
Change the type of
ValidationError.propertyName
fromstring
tostring | Array<string>
(or have it always be an array). Perhaps change the name ofValidationError.propertyName
to the pluralValidationError.propertyNames
I think this fits fairly nicely into the existing paradigm.
This will help with #351