Implements a input validator
npm install @polymer/iron-validator-behavior


IronValidatorBehavior to implement a custom input/form validator. ElementIronValidatableBehavior.See: Documentation,
Demo.
npm install --save @polymer/iron-validator-behavior
`$3
`js
import {PolymerElement, html} from '@polymer/polymer';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
import {IronValidatorBehavior} from '@polymer/iron-validator-behavior/iron-validator-behavior.js';class SampleValidator extends mixinBehaviors([IronValidatorBehavior], PolymerElement){
// This validator only validates strings, and is only valid if
// the value is "cat".
function validate(value) {
return value === 'cat';
}
}
customElements.define('sample-validator', SampleValidator);
`$3
`html
`Contributing
If you want to send a PR to this element, here are
the instructions for running the tests and demo locally:$3
`sh
git clone https://github.com/PolymerElements/iron-validator-behavior
cd iron-validator-behavior
npm install
npm install -g polymer-cli
`$3
`sh
polymer serve --npm
open http://127.0.0.1:/demo/
`$3
`sh
polymer test --npm
``