aurelia / validation

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

Validate nested #181

Closed RWOverdijk closed 8 years ago

RWOverdijk commented 8 years ago

Hello,

I'm trying to use this module like this: https://gist.github.com/RWOverdijk/fd75b26c0a6ac3683dbe

What I'm trying to do, is contain validation within models. However, what happens, is that validation uses the names of the properties (such as name, address, postcode) as key.

Validation does work, but visual feedback doesn't. The reason for this, is that the strategies look for elements that have the property name as value for one of the following attributes: 'validate', 'value.bind', 'value.two-way'.

In my case, this won't work, because the model is referenced using location.name, which isn't location.

How can I work around, or fix, this in this module?

RWOverdijk commented 8 years ago

Small update, I know now I can use the validate attribute to define the property. I'd still prefer a different approach, but it works for me.

On the subject of nested validations I am curious how I should specify something that states that the property is an object, of which I wish to validate specific properties.

export default class Article extends Entity {
  @ensure(it => it.isNotEmpty().hasLengthBetween(3, 20))
  name = null;

  // This is an object. I wish to validate id and foo, too. I don't know how to apply rules to these.
  user = {id: 1, username: 'foo'};
}
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!