Blame view
imports/client/views/core/validations.js
526 Bytes
eb7931b25
|
1 |
export const isRequired = (fieldName, value) => { |
eb7931b25
|
2 3 4 5 |
if (!value) { return fieldName ? `${fieldName} is required` : 'Required' } } |
07ce8d1c9
|
6 7 8 9 10 11 12 13 14 |
export const minLength = minLength => { return value => value && value.length < minLength && `Min. length: ${minLength}` } export const isValidEmail = value => { const exR = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ return !exR.test(value) && 'Please use a valid email' } |