add default role, remove role requirement from validation
This commit is contained in:
1 parent
c2ffdd1d62
commit
99d416f31a
2 files changed
+20
-13
No files matched your search
@@ -15,6 +15,7 @@ const InviteTokenSchema = mongoose.Schema(
|
|||||||
role: {
|
role: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
default: ["user"],
|
||||||
},
|
},
|
||||||
token: {
|
token: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
+19
-13
@@ -63,11 +63,7 @@ const registrationBodyValidation = joi.object({
|
|||||||
}),
|
}),
|
||||||
password: joi.string().min(8).required().pattern(passwordPattern),
|
password: joi.string().min(8).required().pattern(passwordPattern),
|
||||||
profileImage: joi.any(),
|
profileImage: joi.any(),
|
||||||
role: joi
|
role: joi.array().items(joi.string().valid("superadmin", "admin", "user", "demo")),
|
||||||
.array()
|
|
||||||
.items(joi.string().valid("superadmin", "admin", "user", "demo"))
|
|
||||||
.min(1)
|
|
||||||
.required(),
|
|
||||||
teamId: joi.string().allow("").required(),
|
teamId: joi.string().allow("").required(),
|
||||||
inviteToken: joi.string().allow("").required(),
|
inviteToken: joi.string().allow("").required(),
|
||||||
});
|
});
|
||||||
@@ -305,7 +301,18 @@ const getChecksParamValidation = joi.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getChecksQueryValidation = joi.object({
|
const getChecksQueryValidation = joi.object({
|
||||||
type: joi.string().valid("http", "ping", "pagespeed", "hardware", "docker", "port", "distributed_http", "distributed_test"),
|
type: joi
|
||||||
|
.string()
|
||||||
|
.valid(
|
||||||
|
"http",
|
||||||
|
"ping",
|
||||||
|
"pagespeed",
|
||||||
|
"hardware",
|
||||||
|
"docker",
|
||||||
|
"port",
|
||||||
|
"distributed_http",
|
||||||
|
"distributed_test"
|
||||||
|
),
|
||||||
sortOrder: joi.string().valid("asc", "desc"),
|
sortOrder: joi.string().valid("asc", "desc"),
|
||||||
limit: joi.number(),
|
limit: joi.number(),
|
||||||
dateRange: joi.string().valid("recent", "hour", "day", "week", "month", "all"),
|
dateRange: joi.string().valid("recent", "hour", "day", "week", "month", "all"),
|
||||||
@@ -578,16 +585,15 @@ const triggerNotificationBodyValidation = joi.object({
|
|||||||
|
|
||||||
const createAnnouncementValidation = joi.object({
|
const createAnnouncementValidation = joi.object({
|
||||||
title: joi.string().required().messages({
|
title: joi.string().required().messages({
|
||||||
'string.empty': 'Title cannot be empty',
|
"string.empty": "Title cannot be empty",
|
||||||
'any.required': 'Title is required',
|
"any.required": "Title is required",
|
||||||
}),
|
}),
|
||||||
message: joi.string().required().messages({
|
message: joi.string().required().messages({
|
||||||
'string.empty': 'Message cannot be empty',
|
"string.empty": "Message cannot be empty",
|
||||||
'any.required': 'Message is required',
|
"any.required": "Message is required",
|
||||||
}),
|
}),
|
||||||
userId: joi.string().required(),
|
userId: joi.string().required(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
roleValidatior,
|
roleValidatior,
|
||||||
@@ -651,5 +657,5 @@ export {
|
|||||||
imageValidation,
|
imageValidation,
|
||||||
triggerNotificationBodyValidation,
|
triggerNotificationBodyValidation,
|
||||||
webhookConfigValidation,
|
webhookConfigValidation,
|
||||||
createAnnouncementValidation
|
createAnnouncementValidation,
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user