How to use the joi.any function in joi

To help you get started, we’ve selected a few joi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kidtronnix / hapi-dash / servers / gui / auth / index.js View on Github external
handler: function(request, next) {


                var newUser = request.payload;

                var validSchema = Joi.object().keys({
                    fname: Joi.string().required(),
                    lname: Joi.string().required(),
                    email: Joi.string().email().required(),
                    password: Joi.string().alphanum().required().min(5).max(15),
                    password2: Joi.any().valid(newUser.password)
                })

                // We got everything we need to create a new user
                Joi.validate(newUser, validSchema, {abortEarly: false}, function (err, value) {

                    if(err !== null) {
                        console.log(err)

                        var message = '';
                        for(i=0; i < err.details.length; i++)
                        {
                            var _message = err.details[i].message;
                            if(err.details[i].path == 'password2') {
                                message += 'Passwords must match. '
                            } else {
                                message += _message.substr(0, 1).toUpperCase() + _message.substr(1) +'. ';
github js-dxtools / webpack-validator / src / index.js View on Github external
progress: Joi.boolean(),
    recordsInputPath: looksLikeAbsolutePath,
    recordsOutputPath: looksLikeAbsolutePath,
    recordsPath: looksLikeAbsolutePath,
    resolve: resolveSchema,
    resolveLoader: resolveSchema.concat(Joi.object({
      moduleTemplates: Joi.array().items(Joi.string()),
    })),
    watch: Joi.boolean(),
    watchOptions: watchOptionsSchema,
    performance: performanceSchema,
    stats: Joi.any(), // TODO
    target: Joi.any(), // TODO

    // Plugins
    postcss: Joi.any(),
    eslint: Joi.any(),
    tslint: Joi.any(),
    metadata: Joi.any(),
  })
  return schemaExtension ? schema.concat(schemaExtension) : schema
}
github haowen737 / koa-swapi / lib / swagger / builder.js View on Github external
* schema for swagger root object
 */
builder.schema = Joi.object({
  swagger: Joi.string().valid('2.0').required(),
  info: Joi.any(),
  host: Joi.string(), // JOI hostname validator too strict
  basePath: Joi.string().regex(/^\//),
  schemes: Joi.array()
    .items(Joi.string().valid(['http', 'https', 'ws', 'wss']))
    .optional(),
  consumes: Joi.array().items(Joi.string()),
  produces: Joi.array().items(Joi.string()),
  paths: Joi.any(),
  definitions: Joi.any(),
  parameters: Joi.any(),
  responses: Joi.any(),
  securityDefinitions: Joi.any(),
  security: Joi.any(),
  grouping: Joi.string().valid(['path', 'tags']),
  tagsGroupingFilter: Joi.func(),
  tags: Joi.any(),
  cors: Joi.boolean(),
  externalDocs: Joi.object({
    description: Joi.string(),
    url: Joi.string().uri()
  }),
  cache: Joi.object({
    expiresIn: Joi.number(),
    expiresAt: Joi.string(),
    generateTimeout: Joi.number()
  })
})
github bcvsolutions / CzechIdMng / Realization / frontend / czechidm-core / src / components / basic / AbstractFormComponent / AbstractFormComponent.js View on Github external
getValidationDefinition(required) {
    const { validation } = this.props;
    //
    let _validation;
    if (required === true) {
      _validation = this.getRequiredValidationSchema(validation);
      if (validation) {
        _validation = validation.concat(_validation);
      }
    } else {
      // this is default value for not required value
      const notMandatory = Joi.any().empty('');
      _validation = validation ? notMandatory.concat(validation) : notMandatory;
    }
    return _validation;
  }
github arangodb / arangodb / js / apps / system / _admin / aardvark / APP / aardvark.js View on Github external
})
.pathParam('name', joi.string().required(), 'Name of the example graph.')
.summary('Create example graphs')
.description(dd`
  Create one of the given example graphs.
`);

authRouter.post('/job', function (req, res) {
  let frontend = db._collection('_frontend');
  frontend.save(Object.assign(req.body, {model: 'job'}));
  res.json(true);
})
.body(joi.object({
  id: joi.any().required(),
  collection: joi.any().required(),
  type: joi.any().required(),
  desc: joi.any().required()
}).required())
.summary('Store job id of a running job')
.description(dd`
  Create a new job id entry in a specific system database with a given id.
`);

authRouter.delete('/job', function (req, res) {
  let frontend = db._collection('_frontend');
  if (frontend) {
    frontend.removeByExample({model: 'job'}, false);
  }
  res.json(true);
})
.summary('Delete all jobs')
.description(dd`
github vudash / vudash / src / transports / value / index.js View on Github external
get configValidation () {
    return Joi.object({
      value: Joi.any().required().description('Value to return')
    })
  }
github MyScienceWork / PolarisOS / app / modules / entities / publication / models / publications.js View on Github external
const PipelineTypeFiles = require('./pipeline_type_files');
const PipelineDiffusion = require('./pipeline_diffusion');

const Mapping: Object = PubMapping.msw.mappings.publication.properties;

const Validation: Array = [
    {
        title: Joi.object({
            content: Joi.string().required().label('title'),
        }),
        dates: Joi.object({
            publication: Joi.number().required().label('dates.publication'),
        }),
    },
    Joi.object({
        contributors: Joi.array().min(1).required().items(Joi.any().required()).label('contributors'),
        lang: Joi.string().required().label('lang'),
    }),
];

const Formatting: Array = [
    {
        abstracts: a => FormatFunctions.oarray_to_array(a),
        classifications: a => FormatFunctions.oarray_to_array(a),
        contributors: a => FormatFunctions.oarray_to_array(a),
        book_authors: a => FormatFunctions.oarray_to_array(a),
        'diffusion.projects': a => FormatFunctions.oarray_to_array(a),
        'diffusion.anr_projects': a => FormatFunctions.oarray_to_array(a),
        'diffusion.european_projects': a => FormatFunctions.oarray_to_array(a),
        'diffusion.surveys': a => FormatFunctions.oarray_to_array(a),
        'diffusion.research_teams': a => FormatFunctions.oarray_to_array(a),
        files: a => FormatFunctions.oarray_to_array(a),
github ArkEcosystem / core / packages / core-elasticsearch / lib / server / handler.js View on Github external
stats: Joi.any(),
        suggestField: Joi.string(),
        suggestMode: Joi.string(),
        suggestSize: Joi.number(),
        suggestText: Joi.string(),
        timeout: Joi.string(),
        trackScores: Joi.boolean(),
        trackTotalHits: Joi.boolean(),
        typedKeys: Joi.boolean(),
        version: Joi.boolean(),
        requestCache: Joi.boolean(),
        batchedReduceSize: Joi.number(),
        maxConcurrentShardRequests: Joi.number(),
        preFilterShardSize: Joi.number(),
        index: Joi.any(),
        type: Joi.any(),
        body: Joi.object(),
      },
    },
  },
}
github brave / vault / src / controllers / session.js View on Github external
reply().code(204)
  }
},

  description: 'Delete session information for a particular user entry',
  notes: 'For the purpose authentication the HTTP body must be present and contain a header/payload pairing, the payload may be any JSON value.',
  tags: [ 'api' ],

  validate:
    { params:
      { userId: Joi.string().guid().required().description('the identity of the user entry'),
        sessionId: Joi.string().guid().required().description('the identity of the session'),
        type: Joi.string().min(1).required().description('the name of the type')
      },
      query: { message: helper.add_header_schema(Joi.any()).required() }
    },

  response: { schema: Joi.any() }
}

module.exports.routes =
[ braveHapi.routes.async().path('/v1/users/{userId}/sessions').config(v1.readSessions),
  braveHapi.routes.async().path('/v1/users/{userId}/sessions/{sessionId}/types').config(v1.readTypes),
  braveHapi.routes.async().path('/v1/users/{userId}/sessions/{sessionId}/types/{type}').config(v1.readSessionType),
  braveHapi.routes.async().put().path('/v1/users/{userId}/sessions/{sessionId}/types/{type}').config(v1.writeSessionType),
  braveHapi.routes.async().delete().path('/v1/users/{userId}/sessions/{sessionId}/types/{type}').config(v1.deleteSessionType)
]

module.exports.initialize = async function (debug, runtime) {
  runtime.db.checkIndices(debug,
  [ { category: runtime.db.get('sessions', debug),