Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/src/Hooks/useMonitorForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const useMonitorForm = ({
url: data?.url || "",
ignoreTlsErrors: data?.ignoreTlsErrors || false,
useAdvancedMatching: data?.useAdvancedMatching || false,
acceptedStatusCodes: data?.acceptedStatusCodes || "",
matchMethod: data?.matchMethod || "",
expectedValue: data?.expectedValue || "",
jsonPath: data?.jsonPath || "",
Expand Down Expand Up @@ -130,6 +131,7 @@ export const useMonitorForm = ({
url: "",
ignoreTlsErrors: false,
useAdvancedMatching: false,
acceptedStatusCodes: "",
matchMethod: "",
expectedValue: "",
jsonPath: "",
Expand Down
22 changes: 22 additions & 0 deletions client/src/Pages/CreateMonitor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,28 @@ const CreateMonitorPage = () => {
subtitle={t("pages.createMonitor.form.advanced.description")}
rightContent={
<Stack spacing={theme.spacing(LAYOUT.MD)}>
<Controller
name="acceptedStatusCodes"
control={control}
render={({ field, fieldState }) => (
<TextField
{...field}
value={field.value ?? ""}
fieldLabel={t(
"pages.createMonitor.form.advanced.option.acceptedStatusCodes.label"
)}
placeholder="200, 204, 401"
fullWidth
error={!!fieldState.error}
helperText={
fieldState.error?.message ??
t(
"pages.createMonitor.form.advanced.option.acceptedStatusCodes.description"
)
}
/>
)}
/>
<Controller
name="useAdvancedMatching"
control={control}
Expand Down
1 change: 1 addition & 0 deletions client/src/Types/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface Monitor {
type: MonitorType;
ignoreTlsErrors: boolean;
useAdvancedMatching: boolean;
acceptedStatusCodes?: string;
jsonPath?: string;
expectedValue?: string;
matchMethod?: MonitorMatchMethod;
Expand Down
8 changes: 8 additions & 0 deletions client/src/Validation/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { DnsRecordTypes, PageSpeedStrategies } from "@/Types/Monitor";

// URL schema with custom error message
const urlSchema = z.url({ message: "Please enter a valid URL" });
const acceptedStatusCodesSchema = z
.string()
.optional()
.refine(
(value) => !value || /^\s*[1-5]\d{2}(?:\s*,\s*[1-5]\d{2})*\s*$/.test(value),
"Enter comma-separated HTTP status codes between 100 and 599"
);

// Common base schema for all monitor types
const baseSchema = z.object({
Expand Down Expand Up @@ -37,6 +44,7 @@ const httpSchema = baseSchema.extend({
url: urlSchema,
ignoreTlsErrors: z.boolean(),
useAdvancedMatching: z.boolean(),
acceptedStatusCodes: acceptedStatusCodesSchema,
matchMethod: z.enum(["equal", "include", "regex", ""]).optional(),
expectedValue: z.string().optional(),
jsonPath: z.string().optional(),
Expand Down
14 changes: 11 additions & 3 deletions client/src/Validation/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const nameSchema = joi
.string()
.max(50)
.trim()
.pattern(/^[\p{L}\p{M}''()\-\. ]+$/u)
.pattern(/^[\p{L}\p{M}''(). -]+$/u)
.messages({
"string.empty": "auth.common.inputs.firstName.errors.empty",
"string.max": "auth.common.inputs.firstName.errors.length",
Expand All @@ -31,7 +31,7 @@ const lastnameSchema = joi
.string()
.max(50)
.trim()
.pattern(/^[\p{L}\p{M}''()\-\. ]+$/u)
.pattern(/^[\p{L}\p{M}''(). -]+$/u)
.messages({
"string.empty": "auth.common.inputs.lastName.errors.empty",
"string.max": "auth.common.inputs.lastName.errors.length",
Expand Down Expand Up @@ -235,6 +235,14 @@ const monitorValidation = joi.object({
expectedValue: joi.string().allow(null, ""),
jsonPath: joi.string().allow(null, ""),
matchMethod: joi.string().allow(null, ""),
acceptedStatusCodes: joi
.string()
.allow(null, "")
.pattern(/^\s*[1-5]\d{2}(?:\s*,\s*[1-5]\d{2})*\s*$/)
.messages({
"string.pattern.base":
"Enter comma-separated HTTP status codes between 100 and 599",
}),
gameId: joi.when("type", {
is: "game",
then: joi.string().required().messages({
Expand Down Expand Up @@ -414,7 +422,7 @@ const infrastructureMonitorValidation = joi.object({
.trim()
.custom((value, helpers) => {
const urlRegex =
/^(https?:\/\/)?(([0-9]{1,3}\.){3}[0-9]{1,3}|[\da-z\.-]+)(\.[a-z\.]{2,6})?(:(\d+))?([\/\w \.-]*)*\/?$/i;
/^(https?:\/\/)?(([0-9]{1,3}\.){3}[0-9]{1,3}|[\da-z.-]+)(\.[a-z.]{2,6})?(:(\d+))?([/\w .-]*)*\/?$/i;

if (!urlRegex.test(value)) {
return helpers.error("string.invalidUrl");
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "يساوي",
"include": "يحتوي",
"regex": "تعبير عادي"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "إعدادات متقدمة"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Igual",
"include": "Inclou",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Configuració avançada"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Rovná se",
"include": "Obsahuje",
"regex": "Regulární výraz"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Pokročilá nastavení"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Gleich",
"include": "Enthält",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Erweiterte Einstellungen"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@
"advancedMatching": {
"label": "Use advanced matching"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
},
"expectedValue": {
"label": "Expected value"
},
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Igual",
"include": "Contiene",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Configuración avanzada"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Yhtä suuri",
"include": "Sisältää",
"regex": "Säännöllinen lauseke"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Lisäasetukset"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Égal",
"include": "Inclure",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Paramètres avancés"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "等しい",
"include": "含む",
"regex": "正規表現"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "詳細設定"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Igual",
"include": "Inclui",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Configurações avançadas"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Равный",
"include": "Включить",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Расширенные настройки"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "เท่ากับ",
"include": "รวม",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "ตั้งค่าขั้นสูง"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Eşit",
"include": "İçerir",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Gelişmiş ayarlar"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Дорівнює",
"include": "Містить",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Розширені налаштування"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "Bằng",
"include": "Bao gồm",
"regex": "Regex"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "Cài đặt nâng cao"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "相等",
"include": "包含",
"regex": "正则表达式"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "高级设置"
Expand Down
4 changes: 4 additions & 0 deletions client/src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@
"equal": "等於",
"include": "包含",
"regex": "正規表達式"
},
"acceptedStatusCodes": {
"description": "Comma-separated HTTP status codes that should count as up. Leave empty to use the default 2xx response check.",
"label": "Accepted status codes"
}
},
"title": "進階設定"
Expand Down
Loading
Loading