How to use the any function from joi

Find comprehensive JavaScript joi.any code examples handpicked from public code repositorys.

75
76
77
78
79
80
81
82
83
84
85
  // post bus event
  return newAttachments
}


createAttachment.schema = {
  currentUser: Joi.any(),
  challengeId: Joi.id(),
  attachments: Joi.array().items(Joi.object().keys({
    name: Joi.string().required(),
    url: Joi.string().uri().required(),
fork icon44
star icon17
watch icon25

+ 5 other calls in file

2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
    }).unknown(true)).min(1),
    terms: Joi.array().items(Joi.object().keys({
      id: Joi.id(),
      roleId: Joi.id()
    }).unknown(true)).optional().allow([]),
    overview: Joi.any().forbidden()
  }).unknown(true).required()
}


/**
fork icon44
star icon17
watch icon25

+ 9 other calls in file

2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
        Joi.object().keys({
          id: Joi.id(),
          roleId: Joi.id(),
        })
      ),
      overview: Joi.any().forbidden(),
    })
    .unknown(true)
    .required(),
};
fork icon44
star icon17
watch icon25

+ 31 other calls in file

72
73
74
75
76
77
78
79
80
81
city: Joi.string().trim(),
country: Joi.string().trim().allow(""),
cityCode: Joi.string().trim().allow(""),
region: Joi.string().trim().allow(""),
department: Joi.string().trim().allow(""),
location: Joi.any(),
addressVerified: Joi.boolean(),
foreignAddress: Joi.string().trim().allow(""),
foreignZip: Joi.string().trim().allow(""),
foreignCity: Joi.string().trim().allow(""),
fork icon4
star icon8
watch icon4

+ 4 other calls in file

157
158
159
160
161
162
163
164
165
166
 * @private
 */
_validateRequestParams (params) {
  return joi.object().label('params').keys(this._validationSchema)
    .required()
    .pattern(/^$/, joi.any()).pattern(/^__ow_.+$/, joi.any()) // this means allow all unknown parameters that start with __ow_ and ''
    .validate(params)
}

/**
fork icon11
star icon10
watch icon22

47
48
49
50
51
52
53
54
55
    Joi.number().integer()
],

send: [
    Joi.number().integer(),
    Joi.any()
],

info: [],
fork icon1
star icon21
watch icon6

71
72
73
74
75
76
77
78
79
80
const filepondFileParam = Joi.object({
  id: Joi.string().length(24).optional()
}).label('filepondFileParam');

const filepondFilePayload = Joi.object({
  filepond: Joi.any().meta({ swaggerType: 'file' }).allow('').optional()
}).label('filepondFilePayload');

exports.plugin = {
  name: 'routes-default',
fork icon0
star icon7
watch icon4

+ 3 other calls in file

273
274
275
276
277
278
279
280
281
282
  res.json(user.extra.queries);
})
.pathParam('user', joi.string().required(), 'Username. Ignored if authentication is enabled.')
.body(joi.array().items(joi.object({
  name: joi.string().required(),
  parameter: joi.any().optional(),
  value: joi.any().optional()
}).required()).required(), 'User query array to import.')
.error('not found', 'User does not exist.')
.summary('Upload user queries')
fork icon811
star icon0
watch icon0

+ 5 other calls in file

31
32
33
34
35
36
37
38
39
40
    regex: "pattern",
};
function translateWhen(when, validation) {
    if (validation === void 0) { validation = null; }
    if (!validation)
        validation = Joi.any();
    var ref = null;
    if ("reference" in when) {
        ref = Utils_1.jsonToRef(when.reference);
        delete when.reference;
fork icon3
star icon12
watch icon0

+ 3 other calls in file

40
41
42
43
44
45
46
47
48
49
50
51
      return value
    }


    return value
  }),
  results: Joi.any()
});


function createModel (currentlyIrrigating, errorList, currentData, plannedData, hasScore) {
  return {
fork icon2
star icon3
watch icon0

86
87
88
89
90
91
92
93
94
95
joi.object().optional()
  .pattern(RE_EMPTY, joi.forbidden())
  .pattern(RE_NOT_EMPTY, (
    joi.object().required()
      .keys({
        default: joi.any().optional(),
        type: (
        joi.only(Object.keys(configTypes))
          .default('string')
        ),
fork icon816
star icon0
watch icon338

68
69
70
71
72
73
74
75
76
77
        joiValidation = joiValidation.default(NO_DEFAULT);
      }
    }
  }
  else {
    joiValidation = Joi.any().default(NO_DEFAULT);
  }

  return getValue(envName, joiValidation, defaults);
};
fork icon1
star icon0
watch icon2

+ 3 other calls in file

99
100
101
102
103
104
105
106
107
108
const questionValSchema = Joi.object().keys({
  options: Joi.array().items(
    Joi.object({
      optionLabel: Joi.required(),
      isTrue: Joi.boolean().required(),
      placeholder: Joi.any(),
      lastSelectNumber: Joi.number(),
      isSelected: Joi.boolean(),
    })
  ),
fork icon0
star icon0
watch icon1

+ 2 other calls in file

384
385
386
387
388
389
390
391
392
393

Marks a key as forbidden which will not allow any value except `undefined`. Used to explicitly forbid keys.

```js
const schema = {
    a: Joi.any().forbidden()
};
```

#### `any.strip()`
fork icon0
star icon0
watch icon0

+ 35 other calls in file

139
140
141
142
143
144
145
146
147
        Joi.string().required(),
        Joi.array().includes(Joi.string()).min(1).required()
    ],
    path: Joi.string().required(),
    vhost: [Joi.string(), Joi.array()],
    handler: Joi.any(),                         // Validated in route.config
    config: Joi.object().allow(null)
};

fork icon0
star icon0
watch icon4

194
195
196
197
198
199
200
201
202
203
204
205
206
  }


  return result;
};


const joiValidateResponse = (response, joiValidator = Joi.any()) => {
  if (developmentMode) {
    const { error } = joiValidator.validate(response);


    if (error) {
fork icon0
star icon0
watch icon1

+ 2 other calls in file

22
23
24
25
26
27
28
29
30
31
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Joi = __importStar(require("joi"));
const AnswerSchema = Joi.object().keys({
    answer: Joi.any().required(),
    isCorrect: Joi.boolean().required()
});
const QuestionSchema = Joi.object().keys({
    question: Joi.string().required(),
fork icon0
star icon0
watch icon1

306
307
308
309
310
311
312
313
314
315
316
);


const RollupLambdaSchema = condition(
  (s) => defined(s.granularity) || defined(s.timeDimension),
  {
    type: Joi.any().valid('rollupLambda').required(),
    granularity: GranularitySchema,
    timeDimension: Joi.func().required(),
    rollups: Joi.func().required(),
    measures: Joi.func(),
fork icon0
star icon0
watch icon149

+ 139 other calls in file

102
103
104
105
106
107
108
109
110
111
  'InputMessage.data.Quote.Risk.vehicles.usage.estimatedAnnualDistance',
),
principalOperatorIndex: Joi.number().label(
  'InputMessage.data.Quote.Risk.vehicles.usage.principalOperatorIndex',
),
principalOperatorName: Joi.any().label(
  'InputMessage.data.Quote.Risk.vehicles.usage.principalOperatorName',
),
occasionalOperatorIndex: Joi.number().label(
  'InputMessage.data.Quote.Risk.vehicles.usage.occasionalOperatorIndex',
fork icon0
star icon0
watch icon0

+ 3 other calls in file

76
77
78
79
80
81
82
83
84
85
//I want to validate object using Joi which inovle use of Joi.ref() with multiplication operation.
k: Joi.number().integer(),
p: Joi.number().integer().min(1).max(Joi.ref('k', {
    adjust: (value) => value * 2
})).error(new Error('positive number dal mere bhai')),
c: Joi.any().allow('a'),
d: Joi.any().allow('b', 'B'),

//alter any 
key: Joi.string()
fork icon0
star icon0
watch icon0

+ 15 other calls in file