2020-02-27 21:26:18 +01:00
|
|
|
'use strict';
|
|
|
|
|
2020-07-31 22:15:09 +02:00
|
|
|
const joi = require('joi');
|
2021-02-12 10:23:43 +01:00
|
|
|
const { nameType } = require('../routes/admin-api/util');
|
2020-02-27 21:26:18 +01:00
|
|
|
|
|
|
|
const nameSchema = joi.object().keys({ name: nameType });
|
|
|
|
|
|
|
|
const contextSchema = joi
|
|
|
|
.object()
|
|
|
|
.keys({
|
|
|
|
name: nameType,
|
|
|
|
description: joi
|
|
|
|
.string()
|
2020-10-04 20:36:40 +02:00
|
|
|
.max(250)
|
2020-02-27 21:26:18 +01:00
|
|
|
.allow('')
|
|
|
|
.allow(null)
|
|
|
|
.optional(),
|
|
|
|
legalValues: joi
|
|
|
|
.array()
|
|
|
|
.allow(null)
|
|
|
|
.unique()
|
|
|
|
.optional()
|
2020-10-04 20:36:40 +02:00
|
|
|
.items(joi.string().max(100)),
|
2021-02-11 17:59:16 +01:00
|
|
|
stickiness: joi
|
|
|
|
.boolean()
|
|
|
|
.optional()
|
|
|
|
.default(false),
|
2020-02-27 21:26:18 +01:00
|
|
|
})
|
|
|
|
.options({ allowUnknown: false, stripUnknown: true });
|
|
|
|
|
|
|
|
module.exports = { contextSchema, nameSchema };
|