Blame view

imports/client/views/core/validations.js 526 Bytes
eb7931b25   Rafael Arenas Schuchowsky   Improved validati...
1
  export const isRequired = (fieldName, value) => {
eb7931b25   Rafael Arenas Schuchowsky   Improved validati...
2
3
4
5
    if (!value) {
      return fieldName ? `${fieldName} is required` : 'Required'
    }
  }
07ce8d1c9   Rafael Arenas Schuchowsky   New student form ...
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'
  }