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

New features to improve support for instance-level validation #348

Closed
dkent600 opened this issue Sep 26, 2016 · 2 comments
Closed

New features to improve support for instance-level validation #348

dkent600 opened this issue Sep 26, 2016 · 2 comments

Comments

@dkent600
Copy link
Contributor

dkent600 commented Sep 26, 2016

I'm submitting a feature request

  • Library Version:
    0.12.5
  • Browser:
    any
  • Language:
    Typescript 2.0

Current behavior:
Aurelia-Validation has some great features for validating both properties and whole instances. The property-level features seem to be more fleshed-out than the instance-level features. I am developing an application that uses instance-level validation, and would like to propose some new features that will facilitate the use of instance-level validation, and provide more flexibility to the aurelia-validation framework in general.

Feature Requests:

  1. Add the ability to detect when validation state has changed on a specific instance (and specific properties, for that matter). I am currently observing controller.validator.validationMessages.length, but that feels like a hack and doesn't provide any easy information about what changed (property or instance).

Possible solutions: Add callback methods in the ValidationController or its Validator? Publish an event?

  1. Add the ability to associate multiple propertyNames with a Rule.

Possible solutions: Add a parameter propertyNames to satisfies(instance, propertyNames?: string[]) and change ValidationError.propertyName:string to ValidationError.propertyName: string | Array<string> (or have it always be an array). (Also change the name of the property to be plural?)

  1. Add the ability to facilitate instance-level validation through bindings.

Possible solutions: Create a new binding like validation-errors called validation-object-errors for instance-level (rather than property-level) validation. This new binding would change behavior of the inner validate binding by causing whole object to be validated on each property change (rather than a single property). In the ValidationRenderer, RenderInstruction.object.elements would be filled-in with elements corresponding to all of the propertyNames on all the rules that fail. (Change # 2, above, comes in handy here).

@jdanyow
Copy link
Contributor

jdanyow commented Sep 28, 2016

@dkent600 nice writeup. Thank you for the feedback. I'd like to split this issue up because we have a couple issues open for some of these items.

For item 1, could you review #318 and add any thoughts you have there.

For item 2, could you review #279 and add your scenario and thoughts.

Finally, please open a new issue for the third item, it's not being tracked anywhere yet and sounds like a good idea.

thanks!

@jdanyow jdanyow closed this as completed Sep 28, 2016
@dkent600
Copy link
Contributor Author

@jdanyow Phew, done. See #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants