Last active
September 16, 2017 22:20
-
-
Save JoeStanton/40300d38d56f9b527bb809b235cfc4bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 {SuitType} from "./types"; | |
import {generateSchema} from "flow-runtime"; | |
const validate = (value, type) => { | |
return joi.validate(value, generateSchema(type), { | |
abortEarly: false | |
}); | |
} | |
// Validation calls | |
console.log(validate("Carrot", SuitType)); | |
// Output | |
// { | |
// error: [ValidationError: "value" must be one of [Diamonds, Clubs, Hearts, Spades]], | |
// value: 'Carrot' | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment