How to use the isSchema function from joi
Find comprehensive JavaScript joi.isSchema code examples handpicked from public code repositorys.
236 237 238 239 240 241 242 243 244 245 246
* * @param {Object} joiObj * @return {Boolean} */ utilities.isJoi = function(joiObj) { return joiObj && Joi.isSchema(joiObj) }; /** * does JOI object have children
427
901
27
56 57 58 59 60 61 62 63 64 65
return next(); }; } function getValidator(schema, options = {}) { schema = Joi.isSchema(schema) ? schema : Joi.object(schema); options = { ...DEFAULT_OPTIONS, ...options }; return (obj = {}) => { const { value, error } = schema.validate(obj, options); if (error) {
15
0
0
GitHub: dhis2/app-hub
59 60 61 62 63 64 65 66 67 68
const queryFilterKeys = new Set() let renameMap = rename let validateDescription = validateDescriptions[request.route.path] let renameDescription = renameDescriptions[request.route.path] if (rename && Joi.isSchema(rename)) { if (!renameDescription) { renameDescription = renameDescriptions[request.route.path] = rename.describe() }
4
6
34
12 13 14 15 16 17 18 19 20 21
const createSchema = (schema = {}, options = {}) => { if (!isObject(schema)) { throw new Error('Invalid schema type, should be plain object or existing joi schema') } const isValidSchema = Joi.isSchema(schema) const schemaOptions = { abortEarly: false, ...options }
2
4
9
26 27 28 29 30 31 32 33 34 35
* @return {void} */ function shouldBeSeriousSchema(schema, failures, unknownNotAllowed = false, context) { it('is a Joi schema', function () { schema.should.be.ok() isSchema(schema).should.be.true() }) if (schema.type === 'object') { if (!unknownNotAllowed) { it('allows unknown keys (allow for server evolution)', function () {
0
0
0
joi.string is the most popular function in joi (40578 examples)