Skip to content

Instantly share code, notes, and snippets.

@nerder
Created February 19, 2016 18:10
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 nerder/a3a2e12ba0aa8106eb3c to your computer and use it in GitHub Desktop.
Save nerder/a3a2e12ba0aa8106eb3c to your computer and use it in GitHub Desktop.
const Integer = t.refinement(t.Number, n => n % 1 === 0, 'Integer');
const Hour = t.refinement(Integer, int => int >= 1 && int <= 23, 'Hour');
const Hour12 = t.refinement(Hour, int => int >= 1 && int <= 12, 'Hour12');
const Minute = t.refinement(Integer, int => int >= 0 && int <= 59, 'Minute');
const TimeFormat = t.enums.of([H12, H24], 'TimeFormat');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment