api-console-assets
Version:
This repo only exists to publish api console components to npm
51 lines (39 loc) • 903 B
HTML
<!--
@license
Copyright 2017 Mulesoft.
All rights reserved.
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../iron-validator-behavior.html">
<script>
Polymer({
is: 'cats-only',
behaviors: [
Polymer.IronValidatorBehavior
],
properties: {
message: {
type: String,
value: 'Only cats are allowed'
}
},
validateObject: function(obj) {
var valid = true;
for (var key in obj) {
if (obj[key] !== 'cats') {
valid = false;
break;
}
}
return valid;
},
validate: function(values) {
if (typeof values === 'object') {
return this.validateObject(values);
} else {
var value = Array.isArray(values) ? values.join('') : values;
return value.match(/^(c|ca|cat|cats)?$/) !== null;
}
}
});
</script>