feat: add validations & translations

This commit is contained in:
divocat
2025-10-27 13:06:33 +02:00
parent d4b3377d68
commit f1a6ff3469
9 changed files with 488 additions and 210 deletions

View File

@@ -126,6 +126,19 @@ function createSectionContent(section) {
o.default = "50"
o.rmempty = false;
o.depends("proxy_config_type", "urltest");
o.validate = function (section_id, value) {
if (!value || value.length === 0) {
return true;
}
const parsed = parseFloat(value);
if (/^[0-9]+$/.test(value) && !isNaN(parsed) && isFinite(parsed) && parsed >= 50 && parsed <= 1000) {
return true;
}
return _('Must be a number in the range of 50 - 1000');
};
o = section.option(
form.Value,
@@ -141,6 +154,20 @@ function createSectionContent(section) {
o.rmempty = false;
o.depends("proxy_config_type", "urltest");
o.validate = function (section_id, value) {
if (!value || value.length === 0) {
return true;
}
const validation = main.validateUrl(value);
if (validation.valid) {
return true;
}
return validation.message;
};
o = section.option(
form.Flag,
"enable_udp_over_tcp",