Spaces:
Runtime error
Runtime error
Download utils/validators.js from samlax12/promptbackend: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/samlax12/promptbackend/resolve/main/utils/validators.js
- Command line
-
hf download hf://spaces/samlax12/promptbackend/utils/validators.js
-
curl -L -o validators.js https://huggingface.co/spaces/samlax12/promptbackend/resolve/main/utils/validators.js
1.11 kB
| const Joi = require('joi'); | |
| // 用户验证模式 | |
| const userSchema = Joi.object({ | |
| username: Joi.string().required().min(3).max(30), | |
| password: Joi.string().required().min(6), | |
| }); | |
| // 分类验证模式 | |
| const categorySchema = Joi.object({ | |
| name: Joi.string().required().min(1).max(30), | |
| color: Joi.string().pattern(new RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')), | |
| }); | |
| // 提示词验证模式 | |
| const promptSchema = Joi.object({ | |
| title: Joi.string().required().min(1).max(100), | |
| content: Joi.string().required(), | |
| tags: Joi.array().items(Joi.string()), | |
| }); | |
| // 提示词组验证模式 | |
| const promptGroupSchema = Joi.object({ | |
| name: Joi.string().required().min(1).max(100), | |
| description: Joi.string().allow('', null), | |
| category: Joi.string().pattern(new RegExp('^[0-9a-fA-F]{24}$')), | |
| }); | |
| // DSL文件验证模式 | |
| const dslFileSchema = Joi.object({ | |
| name: Joi.string().required(), | |
| fileData: Joi.string().required(), | |
| mimeType: Joi.string(), | |
| }); | |
| module.exports = { | |
| userSchema, | |
| categorySchema, | |
| promptSchema, | |
| promptGroupSchema, | |
| dslFileSchema, | |
| }; |