Skip to content

Instantly share code, notes, and snippets.

@boutell
Created October 29, 2018 15:12
Show Gist options
  • Save boutell/9b7ea1ddecffec1dc599da7cafbb2174 to your computer and use it in GitHub Desktop.
Save boutell/9b7ea1ddecffec1dc599da7cafbb2174 to your computer and use it in GitHub Desktop.
import ApostropheFieldMixin from '../mixins/ApostropheFieldMixin.js';
export default {
mixins: [ ApostropheFieldMixin ],
name: 'ApostropheStringField',
methods: {
validate(value) {
if (this.field.required) {
if (!value.length) {
return 'required';
}
}
if (this.field.min) {
if (value.length && (value.length < this.field.min)) {
return 'min';
}
}
if (this.field.max) {
if (value.length && (value.length > this.field.max)) {
return 'max';
}
}
return false;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment