Skip to content

Instantly share code, notes, and snippets.

Created June 21, 2017 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9ae8091be32baa744b380519c44aea23 to your computer and use it in GitHub Desktop.
Save anonymous/9ae8091be32baa744b380519c44aea23 to your computer and use it in GitHub Desktop.
Rules
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.`
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