update client side validation
This commit is contained in:
1 parent
d38b51e1ca
commit
7da391fcb8
2 files changed
+6
-45
No files matched your search
@@ -1,40 +0,0 @@
|
|||||||
import { createContext, React } from "react";
|
|
||||||
|
|
||||||
const StatusFormContext = createContext({
|
|
||||||
form: {},
|
|
||||||
setForm: () => {},
|
|
||||||
errors: {},
|
|
||||||
setErrors: () => {},
|
|
||||||
handleBlur: () => {},
|
|
||||||
handleChange: () => {},
|
|
||||||
handelCheckboxChange: () =>{}
|
|
||||||
});
|
|
||||||
|
|
||||||
const StatusFormProvider = ({
|
|
||||||
form,
|
|
||||||
setForm,
|
|
||||||
errors,
|
|
||||||
setErrors,
|
|
||||||
handleBlur,
|
|
||||||
handleChange,
|
|
||||||
handelCheckboxChange,
|
|
||||||
children,
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<StatusFormContext.Provider
|
|
||||||
value={{
|
|
||||||
form,
|
|
||||||
setForm,
|
|
||||||
errors,
|
|
||||||
setErrors,
|
|
||||||
handleBlur,
|
|
||||||
handleChange,
|
|
||||||
handelCheckboxChange,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</StatusFormContext.Provider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { StatusFormContext, StatusFormProvider };
|
|
||||||
@@ -203,7 +203,7 @@ const logoImageValidation = joi
|
|||||||
.allow(null)
|
.allow(null)
|
||||||
.optional(); // Make entire object optional
|
.optional(); // Make entire object optional
|
||||||
|
|
||||||
const publicPageSettingsValidation = joi.object({
|
const statusPageValidation = joi.object({
|
||||||
isPublished: joi.bool(),
|
isPublished: joi.bool(),
|
||||||
companyName: joi
|
companyName: joi
|
||||||
.string()
|
.string()
|
||||||
@@ -213,15 +213,16 @@ const publicPageSettingsValidation = joi.object({
|
|||||||
timezone: joi.string().trim().messages({ "string.empty": "Timezone is required." }),
|
timezone: joi.string().trim().messages({ "string.empty": "Timezone is required." }),
|
||||||
color: joi.string().trim().messages({ "string.empty": "Color is required." }),
|
color: joi.string().trim().messages({ "string.empty": "Color is required." }),
|
||||||
theme: joi.string(),
|
theme: joi.string(),
|
||||||
monitors: joi.array().min(1).items(joi.string().required()).messages({
|
monitors: joi.array().min(1).required().messages({
|
||||||
"string.pattern.base": "Must be a valid monitor ID",
|
"string.pattern.base": "Must be a valid monitor ID",
|
||||||
"array.base": "Monitors must be an array",
|
"array.base": "Monitors must be an array",
|
||||||
|
"array.min": "At least one monitor is required",
|
||||||
"array.empty": "At least one monitor is required",
|
"array.empty": "At least one monitor is required",
|
||||||
"any.required": "Monitors are required",
|
"any.required": "At least one monitor is required",
|
||||||
}),
|
}),
|
||||||
logo: logoImageValidation,
|
logo: logoImageValidation,
|
||||||
showUptimePercentage: joi.boolean(),
|
showUptimePercentage: joi.boolean(),
|
||||||
showBarcode: joi.boolean(),
|
showCharts: joi.boolean(),
|
||||||
});
|
});
|
||||||
const settingsValidation = joi.object({
|
const settingsValidation = joi.object({
|
||||||
ttl: joi.number().required().messages({
|
ttl: joi.number().required().messages({
|
||||||
@@ -337,6 +338,6 @@ export {
|
|||||||
maintenanceWindowValidation,
|
maintenanceWindowValidation,
|
||||||
advancedSettingsValidation,
|
advancedSettingsValidation,
|
||||||
infrastructureMonitorValidation,
|
infrastructureMonitorValidation,
|
||||||
publicPageSettingsValidation,
|
statusPageValidation,
|
||||||
logoImageValidation,
|
logoImageValidation,
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user