mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 10:56:36 +00:00
49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const { yup, validateYupSchema } = require('@strapi/utils');
|
|
const constants = require('../services/constants');
|
|
|
|
const apiTokenCreationSchema = yup
|
|
.object()
|
|
.shape({
|
|
name: yup
|
|
.string()
|
|
.min(1)
|
|
.required(),
|
|
description: yup.string().optional(),
|
|
type: yup
|
|
.string()
|
|
.oneOf(Object.values(constants.API_TOKEN_TYPE))
|
|
.required(),
|
|
permissions: yup
|
|
.array()
|
|
.of(yup.string())
|
|
.nullable(),
|
|
})
|
|
.noUnknown();
|
|
|
|
const apiTokenUpdateSchema = yup
|
|
.object()
|
|
.shape({
|
|
name: yup
|
|
.string()
|
|
.min(1)
|
|
.notNull(),
|
|
description: yup.string().nullable(),
|
|
type: yup
|
|
.string()
|
|
.oneOf(Object.values(constants.API_TOKEN_TYPE))
|
|
.notNull(),
|
|
permissions: yup
|
|
.array()
|
|
.of(yup.string())
|
|
.nullable(),
|
|
lastUsed: yup.date().nullable(),
|
|
})
|
|
.noUnknown();
|
|
|
|
module.exports = {
|
|
validateApiTokenCreationInput: validateYupSchema(apiTokenCreationSchema),
|
|
validateApiTokenUpdateInput: validateYupSchema(apiTokenUpdateSchema),
|
|
};
|