Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 4x 5x 5x 5x 3x 3x 3x 6x 6x | import Joi from "joi";
import { BaseOutputDto } from "../dto.js";
class CreateArticleInputDto {
static SCHEMA = Joi.object({
title: Joi.string().min(3).max(250).required(),
body: Joi.string().max(500000).required(),
tags: Joi.array().items(
Joi.string()
.min(2)
.max(30)
.ruleset.pattern(new RegExp("^[A-z0-9_-]*$"))
.message(
"{{#label}} with value {:[.]} must contain only letters, numbers, dashes (-) and underscores (_)"
)
),
// Regex: alphanum + underscore + dash
}).options({ abortEarly: false });
constructor(data) {
Iif (typeof data.tags == "string" && data.tags != "") {
data.tags = data.tags.split(",");
} else {
data.tags = Array.isArray(data.tags) ? data.tags : [];
}
data = Joi.attempt(data, this.constructor.SCHEMA);
this.title = data.title;
this.body = data.body;
this.tags = data.tags;
}
}
class CreateArticleOutputDto extends BaseOutputDto {
data;
constructor({ _id, title, body, tags }, success = true, info) {
super(success, info);
this.data = {
_id: _id,
title: title,
body: body,
tags: tags,
};
}
}
export { CreateArticleInputDto, CreateArticleOutputDto };
|