Created
June 21, 2017 13:21
-
-
Save anonymous/9ae8091be32baa744b380519c44aea23 to your computer and use it in GitHub Desktop.
Rules
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
export const isRequired = fieldName => `${fieldName} is required.`; | |
export const minLength = length => { | |
return (fieldName) => `${fieldName} must be at least ${length} characters.`; | |
}; | |
export const maxLength = length => { | |
return (fieldName) => `${fieldName} can not be over ${length} characters.`; | |
}; | |
export const loginMustExist = () => `Network ID can not be found or is not authorized to reserve this room.` |
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 * as ErrorMessages from '../Errors' | |
export const required = text => text ? null : ErrorMessages.isRequired | |
export const minLength = (length) => { | |
return (text) => { | |
return text.length >= length ? null : ErrorMessages.minLength(length); | |
}; | |
}; | |
export const maxLength = (length) => { | |
return (text) => { | |
return text.length <= length ? null : ErrorMessages.maxLength(length); | |
}; | |
}; | |
export const loginMustExist = (text) => { | |
return axios.get(`/api/user`, {params: {loginid: text}}) | |
.then(() => null) | |
.catch(() => ErrorMessages.loginMustExist) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment