commit for publication

This commit is contained in:
2026-09-17 14:41:22 +01:00
committed by Jack Clifton
commit 0bf030f3c7
26 changed files with 2506 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
const VALID = true;
const INVALID = false;
class validation {
static mac_addr(addr) {
const VALID_MAC_CHARS = "0123456789abcdefABCDEF";
if (addr.length !== 17) {
return INVALID;
}
const COLON_START_IDX = 2;
const COLON_STEP = 3;
for (let idx = COLON_START_IDX; idx < addr.length; idx += COLON_STEP) {
if (addr[idx] != ":") {
return INVALID;
}
}
const mac_sections = addr.split(":");
if (mac_sections.length !== 6) {
return INVALID;
}
for (const mac_byte of mac_sections) {
if (mac_byte.length !== 2) {
return INVALID;
}
for (const char of mac_byte) {
if (!VALID_MAC_CHARS.includes(char)) {
return INVALID;
}
}
}
return VALID;
}
}