mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-25 00:11:36 +01:00
Add validation for SSID with diacritic
This commit is contained in:
parent
e1d75d8328
commit
35b97ec0fe
|
@ -63,6 +63,16 @@ function prepDataToSubmit(formData) {
|
|||
return formData;
|
||||
}
|
||||
|
||||
function diacriticValidation(string) {
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
const charCode = string.charCodeAt(i);
|
||||
if (charCode < 32 || charCode > 127) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function validator(formData) {
|
||||
const formErrors = formData.devices.map((device) => {
|
||||
if (!device.enabled) return {};
|
||||
|
@ -71,6 +81,10 @@ export function validator(formData) {
|
|||
if (device.SSID.length > 32)
|
||||
errors.SSID = _("SSID can't be longer than 32 symbols");
|
||||
if (device.SSID.length === 0) errors.SSID = _("SSID can't be empty");
|
||||
if (!diacriticValidation(device.SSID))
|
||||
errors.SSID = _(
|
||||
"Your SSID contains non-standard characters. These are not forbidden, but could cause problems on some devices."
|
||||
);
|
||||
|
||||
if (device.password.length < 8)
|
||||
errors.password = _("Password must contain at least 8 symbols");
|
||||
|
|
Loading…
Reference in New Issue
Block a user