Skip to content

Instantly share code, notes, and snippets.

@ealush
Last active February 21, 2018 11:20
Show Gist options
  • Select an option

  • Save ealush/42bd30af61846acf7cffc07c91a8f455 to your computer and use it in GitHub Desktop.

Select an option

Save ealush/42bd30af61846acf7cffc07c91a8f455 to your computer and use it in GitHub Desktop.
enforce: custom rules
const enforce = new Enforce({
hasDog: (value) => /dog/.test(value)
});
enforce('dog').hasDog();
// Proxy {isArray: ƒ, largerThan: ƒ, smallerThan: ƒ, isEmpty: ƒ, hasDog: ƒ}
enforce('cat').hasDog();
// Uncaught Error: hasDog: YOU SHALL NOT PASS!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment