mirror of
https://github.com/directus/directus.git
synced 2026-02-02 02:45:01 -05:00
18 lines
284 B
TypeScript
18 lines
284 B
TypeScript
import Joi from 'joi';
|
|
|
|
const schema = Joi.alternatives().try(
|
|
Joi.object({
|
|
name: Joi.string().required(),
|
|
age: Joi.number()
|
|
}),
|
|
Joi.string(),
|
|
).match('all');
|
|
|
|
const value = {
|
|
age: 25
|
|
};
|
|
|
|
const { error } = schema.validate(value);
|
|
|
|
console.log(JSON.stringify(error, null, 2));
|