I have a joi schema called user
const user = {
firstName: Joi.string()
.min(2)
.max(50)
.required()
.label('First Name'),
lastName: Joi.string()
.min(3)
.max(50)
.required()
.label('Last Name'),
email: Joi.string()
.allow('')
.email({ minDomainAtoms: 2 })
.max(100)
.label('Email Address'),
}
I had another one called owner
const ownerSchema = {
firstName: Joi.string()
.min(2)
.max(50)
.required()
.label('First Name'),
lastName: Joi.string()
.min(3)
.max(50)
.required()
.label('Last Name'),
email: Joi.string()
.allow('')
.email({ minDomainAtoms: 2 })
.max(100)
.label('Email Address'),
number: Joi.string()
.regex(/[0-9]/)
.length(10)
.required()
.label('Phone Number'),
dateOfBirth: Joi.date(),
kycDetails: Joi.array()
.items(schemaKyc)
.required(),
bankDetails: Joi.array()
.items(schemaBank)
.required(),
licenceDetails: Joi.array()
.items(schemaLicence)
.required(),
insuranceDetails: Joi.array()
.items(schemaInsurance)
.required()
};
As you can see the both have three fields in common I want to be able to use the user schema in owner and whenever I make changes to the user I want it to reflect in the owner as well.