Created
September 29, 2015 13:48
-
-
Save simon-p-r/51b597f54744b36ac94f to your computer and use it in GitHub Desktop.
Joi issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internals.Schema = Joi.object({ | |
metaSchema: Joi.object().keys({ | |
description: Joi.string(), | |
type: Joi.string().required().valid('collection', 'definition', 'record'), | |
base: Joi.alternatives().when('type', { | |
is: ['record'], | |
then: Joi.string().required() | |
}), | |
jsonSchema: Joi.string(), | |
name: Joi.string().required(), | |
version: Joi.number(), | |
keys: Joi.alternatives().when('type', { | |
is: ['collection', 'record'], | |
then: Joi.array().items(Joi.object({ | |
name: Joi.string(), | |
flds: Joi.object(), | |
options: Joi.object() | |
})) | |
}), | |
sid: Joi.array() | |
}).required(), | |
schema: Joi.object().required(), | |
methods: Joi.object() | |
}).required(); | |
internals.AddArray = Joi.array().items(internals.Schema) | |
internals.SchemaSet = Joi.object({ | |
collections: Joi.object({ | |
}).pattern(/^[a-zA-Z]+$/, internals.Schema), | |
definitions: Joi.object({ | |
}).pattern(/^[a-zA-Z]+$/, internals.Schema), | |
records: Joi.object({ | |
}).pattern(/^[a-zA-Z]+$/, internals.Schema) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to validate incoming parameter to check if it is an object as show in internals.schema or if it is either an array of internal.schema objects or an object with keys - collections, definitions and records which will have unknown key names but its value will be the internal.schema object.