Skip to content

Instantly share code, notes, and snippets.

@Emilios1995
Created July 31, 2017 01:42
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 Emilios1995/e3740b3fe99a2d38883209bb1a3ca3a1 to your computer and use it in GitHub Desktop.
Save Emilios1995/e3740b3fe99a2d38883209bb1a3ca3a1 to your computer and use it in GitHub Desktop.
const typeMessage = (type, field) => `${field} has to be a ${type}`;
const typeRule = type => [
isType(type),
(val, field) => typeMessage(type, field)
];
const isString = typeRule("String");
const isNumber = typeRule("Number")
const rules = {
version: [isNumber],
build: [isNumber],
appName: [isString]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment