PolymerElements / paper-input

A Material Design text field
https://www.webcomponents.org/element/PolymerElements/paper-input
130 stars 162 forks source link

iron-input-validate event cannot be used for custom validation when using auto-validate #622

Open bendavis78 opened 6 years ago

bendavis78 commented 6 years ago

Description

The documentation says that you can use the iron-input-validate event to validate an input. This is not actually possible because the .validate() method returns a value before firing the event, so the event is not able to change the outcome of validation.

Expected outcome

Custom validation using event should be able to set the invalid property.

Actual outcome

The invalid property is overridden because .validate() returns a value before firing an event, and _handleValueAndAutoValidate sets this.invalid based on that return value. Ideally, it should not override this.invalid if it has already been set to false.

Live Demo

https://jsbin.com/joxoyizamo/edit?html,output

Browsers Affected