insomnia/app/validators/requestGroup.js

35 lines
801 B
JavaScript
Raw Normal View History

2016-03-20 20:42:27 +00:00
import {Validator} from 'jsonschema';
const validator = new Validator();
const environmentsSchema = {
id: '/RequestGroupEnvironment',
type: 'object',
2016-03-24 05:26:04 +00:00
properties: {}
2016-03-20 20:42:27 +00:00
};
const requestGroupSchema = {
id: '/RequestGroup',
type: 'object',
properties: {
id: {type: 'string', pattern: '^rg_[\\w]{10}$'},
created: {type: 'number', minimum: 1000000000000, maximum: 10000000000000},
modified: {type: 'number', minimum: 1000000000000, maximum: 10000000000000},
name: {type: 'string', minLength: 1},
environment: {type: 'object'}
},
required: [
'_mode',
'id',
'created',
'modified',
'name',
'environment'
],
additionalProperties: false
};
export default function (requestGroup) {
return validator.validate(requestGroup, requestGroupSchema);
}