Created
July 26, 2018 07:46
-
-
Save slaveofcode/a00f6cc53b2d4204575ec45984ea45a3 to your computer and use it in GitHub Desktop.
Podeng extend object
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
const { blueprint, types, validator } = require('podeng'); | |
const Car = blueprint.object({ | |
wheels: types.integer({ default: 4 }), | |
color: types.options(['Red', 'Green', 'Blue']), | |
brand: types.string | |
}) | |
const Truck = blueprint.extend(Car, { | |
wheels: types.integer({ default: 6 }) | |
}) | |
Truck({brand: 'Volvo'}) // this is ok, since we're not doing validation | |
const truckValidator = validator(Truck); | |
truckValidator.validate({brand: 123, color: 'Green'}) // throw error because have empty value for wheels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment