iron-input icon indicating copy to clipboard operation
iron-input copied to clipboard

validate method supports multiple validators in validatable

Open tlouisse opened this issue 8 years ago • 0 comments

Currently, it's not possible to use multiple validators on an input.

Also see:

  • https://github.com/PolymerElements/paper-input/issues/289
  • https://github.com/PolymerElements/iron-input/issues/53

With this pull request, it will become possible to add multiple validators to elements implementing the validatable behavior, without having to write a new custom validator that combines functionality of other validators.

Along with this functionality, the following will be supported:

  • custom messages:
    • stored in validators (so there's a single source of truth, resulting in consistency between forms and less development work)
    • support for multiple error messages, ordered by priority (the most important message will be shown by the paper-input)
  • support for native validators('required', 'max', 'min', 'step', 'maxlength', 'minlength', 'pattern', 'emailtype'(type=email) and 'urltype' (type=url))
  • automatic instantiating of custom validators
  • possibility to connect unique instances of a validator to a validatable-element (when overriding of the default message will be needed)

Everything is tested for backwards compatibility. All tests have run in chrome 51, firefox 46, OS X 10.9 safari 7, OS X 10.10 safari 8, OS X 10.11 safari 9, Windows 7 IE 10, Windows 8.1 IE 11, Windows 10 microsoftedge, Android 4.3, Android 4.4, Android 5, Android 6, iOS 7, iOS 8, iOS 9.3.

Note that, since the validation functionality is located in different repositories, the above functionality will contain pull requests in the following repositories:

The link below shows an example of what would be the benefit of the old vs. the new situation. It makes clear what the API will look like and how little code will be needed to achieve the same in the new situation.

https://tlouisse.github.io/iron-validatable-behavior/components/iron-validatable-behavior/demo/

tlouisse avatar Sep 08 '16 14:09 tlouisse