Skip to content

Instantly share code, notes, and snippets.

@fbaiodias
Created October 11, 2015 16:21
Show Gist options
  • Save fbaiodias/0348886f0a56ea72ee20 to your computer and use it in GitHub Desktop.
Save fbaiodias/0348886f0a56ea72ee20 to your computer and use it in GitHub Desktop.
Rejoi schema proposal
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