Created
October 11, 2015 16:21
-
-
Save fbaiodias/0348886f0a56ea72ee20 to your computer and use it in GitHub Desktop.
Rejoi schema proposal
This file contains 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 original = { | |
card: Joi.object({ | |
number: Joi.string().creditCard().required(), | |
holderName: Joi.string().required(), | |
expiry: { | |
year: Joi.number().min(2015).min(2025).required(), | |
month: Joi.number().min(1).min(12).required(), | |
} | |
}), | |
billingAddress: Joi.object({ | |
line1: Joi.string(), | |
line2: Joi.string(), | |
postcode: Joi.string(), | |
country: Joi.string(), | |
}) | |
} | |
import ExpiryDate from './expiryDate' | |
import AddressLookup from './addressLookup' | |
const rejoiSchema = Joi.object({ | |
card: Joi.object({ | |
number: Joi.string().creditCard().required().meta({ index: 0 }), | |
holderName: Joi.string().required().meta({ index: 1 }), | |
expiry: Joi.object({ | |
year: Joi.number().min(2015).min(2025).required(), | |
month: Joi.number().min(1).min(12).required(), | |
}).meta({ index: 2, component: 'ExpiryDate' }) | |
}).meta({ index: 0 }), | |
billingAddress: Joi.object({ | |
line1: Joi.string(), | |
line2: Joi.string(), | |
postcode: Joi.string(), | |
country: Joi.string(), | |
}).meta({ index: 1, component: 'AddressLookup' }) | |
}).options({ language: customLanguage }) | |
const components = { | |
ExpiryDate, | |
AddressLookup | |
} | |
<Rejoi schema={rejoiSchema} components={components}></Rejoi> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment