feat(doc): the field rule for a modem's code, which the sheet's commit left behind
87c09c6 uses rule "modemCode" and setModemCode through it; both lived in
these two files, which that commit did not take.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
// " 10.0.0.1"; a phone's keyboard puts a space after a word). A name and an
|
||||
// SSID are taken as typed, spaces included, as Java takes them.
|
||||
|
||||
import { DIRECTLY_CONNECTED_SOURCE_MARKER, IP_ADDRESS_PATTERN, javaIpCheck, parseIPv4 } from '@mdg-filius/core';
|
||||
import { DIRECTLY_CONNECTED_SOURCE_MARKER, IP_ADDRESS_PATTERN, javaIpCheck, modemCodeOf, parseIPv4 } from '@mdg-filius/core';
|
||||
|
||||
export type FieldRule =
|
||||
| 'name'
|
||||
@@ -34,7 +34,9 @@ export type FieldRule =
|
||||
/** A firewall rule's mask: empty, or ones then zeros (EingabenUeberpruefung.isValidSubnetmask). */
|
||||
| 'firewallMask'
|
||||
/** A firewall rule's port: empty for all ports, or musterPort. */
|
||||
| 'portOrEmpty';
|
||||
| 'portOrEmpty'
|
||||
/** The code of another project's modem (modemCodeOf: six characters, spaces, dashes and small letters allowed). */
|
||||
| 'modemCode';
|
||||
|
||||
/** What a field's text comes to: the value the device takes, or that it takes none. */
|
||||
export type CheckedField = { readonly value: string } | { readonly invalid: true };
|
||||
@@ -97,6 +99,10 @@ export function checkField(rule: FieldRule, text: string): CheckedField {
|
||||
}
|
||||
case 'portOrEmpty':
|
||||
return text.trim() === '' ? { value: '' } : checkField('port', text);
|
||||
case 'modemCode': {
|
||||
const code = modemCodeOf(text);
|
||||
return code === undefined ? INVALID : { value: code };
|
||||
}
|
||||
case 'macAddress':
|
||||
// Upper case, as the model keeps MAC addresses (Java keeps them as typed and compares ignoring case).
|
||||
return MAC_ADDRESS_PATTERN.test(text.trim()) ? { value: text.trim().toUpperCase() } : INVALID;
|
||||
|
||||
Reference in New Issue
Block a user