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

Can't manually validate properties that are not bound #477

Open
guiprav opened this issue Feb 20, 2018 · 2 comments
Open

Can't manually validate properties that are not bound #477

guiprav opened this issue Feb 20, 2018 · 2 comments

Comments

@guiprav
Copy link

guiprav commented Feb 20, 2018

I'm submitting a feature request

  • Library Version:
    aurelia-validation@1.1.2

Please tell us about your environment:

  • Operating System:
    Ubuntu 17.10

  • Node Version:
    8.7.0

  • NPM Version:
    5.4.2

  • JSPM OR Webpack AND Version
    Gulp (Aurelia CLI 0.31.3)

  • Browser:
    all

  • Language:
    TypeScript 2.6.2

Current behavior:

validationController.errors remains empty after calling validationController.validate(), even though the property being validated is invalid, unless the property being validated is used in a binding with & validateManually binding behavior.

Demo: https://gist.run/?id=bd62deb898eca7c93a1ed901068090db

  • Click submit button.
  • Notice how first name isn't validated.

Expected/desired behavior:

  • What is the expected behavior?

It should be possible to validate properties that aren't bound to any element. I'm creating a reusable dropdown editor component. Its value is an array of strings. If I bind that to a hidden element, it becomes a comma-separated list of strings, which is pretty inadequate.

  • What is the motivation / use case for changing the behavior?

I've been using an ugly workaround where I set aurelia-validation on an unused property bound to a hidden input element and check the desired property directly from within the validation handlers, but it would be much, much better if Aurelia just allowed me to manually validate any property, regardless of binding behavior.

I think the use cases abound. If this behavior is by design and we want to keep it, can we make it configurable at least?

@Alexander-Taran
Copy link

@jdanyow can you label it? bug or feature?

@m-gallesio
Copy link

In our application we often rely on elements being actually bound in order to determine whether their values should be validated. This allows simpler rule definitions because an if.bind="condition" on a component can eliminate the need of a corresponding .when(condition) in the configuration.

Thus if this is implemented I think it should be configurable and not enforced, unless our use case is considered bad practice.

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

No branches or pull requests

3 participants