2021-09-14 20:36:40 +02:00
|
|
|
import joi from 'joi';
|
|
|
|
import { nameType } from '../routes/util';
|
2020-02-27 21:26:18 +01:00
|
|
|
|
2021-09-14 20:36:40 +02:00
|
|
|
export const nameSchema = joi.object().keys({ name: nameType });
|
2020-02-27 21:26:18 +01:00
|
|
|
|
2022-04-19 08:40:07 +02:00
|
|
|
const legalValueSchema = joi.object().keys({
|
|
|
|
value: joi.string().min(1).max(100).required(),
|
|
|
|
description: joi.string().allow('').allow(null).optional(),
|
|
|
|
});
|
|
|
|
|
2021-09-14 20:36:40 +02:00
|
|
|
export const contextSchema = joi
|
2020-02-27 21:26:18 +01:00
|
|
|
.object()
|
|
|
|
.keys({
|
|
|
|
name: nameType,
|
2021-08-12 15:04:37 +02:00
|
|
|
description: joi.string().max(250).allow('').allow(null).optional(),
|
2020-02-27 21:26:18 +01:00
|
|
|
legalValues: joi
|
|
|
|
.array()
|
|
|
|
.allow(null)
|
2022-04-19 08:40:07 +02:00
|
|
|
.unique((a, b) => a.value === b.value)
|
2020-02-27 21:26:18 +01:00
|
|
|
.optional()
|
2022-04-19 08:40:07 +02:00
|
|
|
.items(legalValueSchema),
|
2021-08-12 15:04:37 +02:00
|
|
|
stickiness: joi.boolean().optional().default(false),
|
2020-02-27 21:26:18 +01:00
|
|
|
})
|
|
|
|
.options({ allowUnknown: false, stripUnknown: true });
|