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
fork icon427
star icon901
watch icon27

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) {
fork icon15
star icon0
watch icon0

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()
    }
fork icon4
star icon6
watch icon34

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
  }
fork icon2
star icon4
watch icon9

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 () {
fork icon0
star icon0
watch icon0