Created
October 29, 2018 15:12
-
-
Save boutell/9b7ea1ddecffec1dc599da7cafbb2174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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