Support @Size for collections
Closed this issue · 1 comments
We would like to use @SiZe annotation on collections on our backend models, and to have appropriate validations on client side too. Example:
@Size(min=3, max=15)
private List<String>
@Size(min=1, max=3)
private List<SomeEnum>
Valdr already have support for @SiZe attribute.
One thing that needs to be implemented-if you need to work with list/array- is that you need to use it on your special element/directive. Valdr works with standard html elements : input, select and textarea.
In this case you can use enableValdrValidation
and enableValdrMessage
directives on some div or within your directive.
Valdr will validate the model, but if you want to show the message with valdrMessage
using default configuration to show them(dirty and touched), then you need to make sure that when changing model value, you need to set $dirty
and $touched
properties to ngModelController
.
I've created small plunker which shows how it's working.