Development
This commit is contained in:
parent
33ec9e7f1c
commit
0cec7d69c9
12 changed files with 124 additions and 92 deletions
|
|
@ -318,7 +318,7 @@ Form-group layout with a badge showing interface state (`UP`/`DOWN`/`INVALID`/ot
|
|||
"scroll_to_bottom?": true
|
||||
}
|
||||
```
|
||||
`<pre>` block for log output. Setting `scroll_to_bottom: true` adds a `data-scroll-bottom` attribute that JS uses to auto-scroll.
|
||||
`<pre>` block for log output. Lines do not wrap; content scrolls horizontally when lines exceed the container width. Setting `scroll_to_bottom: true` adds a `data-scroll-bottom` attribute that JS uses to auto-scroll to the bottom on load and on update.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -507,47 +507,40 @@ Group of hidden credential sub-groups (API token vs. No-IP username/password). J
|
|||
|
||||
## Validation
|
||||
|
||||
The `validate` field attaches a named validator to an input. Validators run live as the user types, show inline hint messages, and keep the form's submit button disabled until all validated fields pass.
|
||||
The `validate` field attaches one or more `VALIDATION_*` flags to an input. Validators run live as the user types, show inline hint messages, and keep the form's submit button disabled until all validated fields pass. Flags are combined with `|`:
|
||||
|
||||
Three mechanisms exist depending on context:
|
||||
```json
|
||||
{ "type": "field", "name": "nat_ip", "validate": "VALIDATION_IPV4_FORMAT|VALIDATION_UNRESTRICTED" }
|
||||
```
|
||||
|
||||
- `field`, `editable_list`: sets `data-validate` on the input. The named classifier runs on every keystroke and marks the field valid, incomplete (warning), or invalid (error).
|
||||
- `overridable_textarea`: sets `data-validate-lines` on the textarea. When the override checkbox is checked, each non-empty line is validated as an IP address. If subnet context is available (from sibling subnet/mask inputs), each line is also checked against that subnet.
|
||||
- `record_editor` fields: use `valtype` instead of `validate`. The field is wired to sibling subnet/mask inputs via `data-dep-subnet` and `data-dep-mask` attributes.
|
||||
All three contexts use the same flag system:
|
||||
|
||||
### `validate` values (for `field` and `editable_list`)
|
||||
- `field`, `editable_list`: sets `data-validate` (bitmask integer) on the input. Validation fires on every keystroke.
|
||||
- `overridable_textarea`: sets `data-validate-lines`. When the override checkbox is checked, each non-empty line is validated individually.
|
||||
- `record_editor` fields: `validate` (or its legacy alias `valtype`) sets `data-validate` on the per-field input.
|
||||
|
||||
| Value | Accepts |
|
||||
|-------|---------|
|
||||
| `ipv4` | IPv4 address. Four dot-separated octets, each 0-255. |
|
||||
| `mac` | MAC address. Six colon-separated two-digit hex groups. |
|
||||
| `url` | HTTP or HTTPS URL. Must begin with `http://` or `https://`, have a valid hostname, and an optional port in range 1-65535. |
|
||||
| `port` | Port number. Integer 1-65535, digits only. |
|
||||
| `ipv4cidr` | IPv4 address or CIDR notation. Accepts a bare IP or `IP/prefix` where prefix is 0-32. |
|
||||
| `endpoint` | Network endpoint. Accepts an IPv4 address, IPv6 address, or hostname. Hostnames may include a `:port` suffix. |
|
||||
| `dashname` | Dash-delimited identifier. Lowercase letters, digits, and hyphens. No leading, trailing, or consecutive hyphens. |
|
||||
| `domainname` | Domain name. Letters, digits, hyphens, and dots. Each label must not start or end with a hyphen. |
|
||||
| `networkname` | Network identifier. Letters, digits, hyphens, and underscores. No leading, trailing, or consecutive special characters. |
|
||||
| `time_24h` | 24-hour time. Format `HH:MM`. Hours 00-23, minutes 00-59. |
|
||||
| `positive_int` | Positive integer. Digits only. Respects the field's `min` and `max` bounds when present. |
|
||||
| `vlan_id` | VLAN ID. Integer 1-4094. Also checks uniqueness against existing IDs read from the input's `data-existing-ids` attribute. |
|
||||
`number` input_type defaults to `VALIDATION_RANGE_INT` when no `validate` is specified.
|
||||
|
||||
### `validate` value (for `overridable_textarea`)
|
||||
### `VALIDATION_*` flags
|
||||
|
||||
| Value | Behavior |
|
||||
|-------|---------|
|
||||
| `ip_in_subnet` | Each non-empty line must be a valid IPv4 address. When the VLAN subnet and mask are both filled in, also verifies each address falls within that subnet. |
|
||||
|
||||
### `valtype` values (for `record_editor` fields)
|
||||
|
||||
`valtype` wires subnet-aware real-time validation using sibling inputs pointed to by `data-dep-subnet` and `data-dep-mask` attributes on the field.
|
||||
|
||||
| Value | Validates |
|
||||
|-------|---------|
|
||||
| `address` | IPv4 host address. Must be a valid IP within the known subnet, and must not be the network or broadcast address. |
|
||||
| `subnet` | IPv4 subnet address. All host bits must be zero for the given mask. |
|
||||
| `mask` | Prefix length. Integer 1-30. |
|
||||
| `format` | IPv4 address format only. No subnet membership check. |
|
||||
| Flag | Accepts |
|
||||
|------|---------|
|
||||
| `VALIDATION_IPV4_FORMAT` | IPv4 address. Four dot-separated octets, each 0-255. |
|
||||
| `VALIDATION_IPV6_FORMAT` | IPv6 address. |
|
||||
| `VALIDATION_SUBNET` | IPv4 subnet address. All host bits must be zero for the prefix length implied by sibling inputs. |
|
||||
| `VALIDATION_ADDRESS` | IPv4 host address. Must fall within the subnet implied by sibling inputs and must not be the network or broadcast address. |
|
||||
| `VALIDATION_MAC` | MAC address. Six colon-separated two-digit hex groups. |
|
||||
| `VALIDATION_URL` | HTTP or HTTPS URL. Must begin with `http://` or `https://` and have a valid hostname. |
|
||||
| `VALIDATION_PORT` | Port number. Integer 1-65535. |
|
||||
| `VALIDATION_DASH_NAME` | Lowercase letters, digits, and hyphens. No leading, trailing, or consecutive hyphens. |
|
||||
| `VALIDATION_NETWORK_NAME` | Letters, digits, hyphens, and underscores. No leading, trailing, or consecutive special characters. |
|
||||
| `VALIDATION_DOMAIN_NAME` | Domain name. Labels of letters, digits, and hyphens separated by dots. No label may start or end with a hyphen. |
|
||||
| `VALIDATION_TIME24H` | 24-hour time. Format `HH:MM`. Hours 00-23, minutes 00-59. |
|
||||
| `VALIDATION_RANGE_INT` | Integer. Respects the field's `min` and `max` bounds when present. Default for `number` input_type. |
|
||||
| `VALIDATION_IPV4_CIDR` | Strict CIDR. A prefix is always required (`192.168.1.0/24`). Host bits must be zero. |
|
||||
| `VALIDATION_IPV4_CIDRFLEX` | Flexible CIDR. Accepts a bare IPv4 address (yellow/incomplete when last octet is 0) or `IP/prefix`. |
|
||||
| `VALIDATION_UNRESTRICTED` | IPv4 address must not fall within any restricted VLAN subnet. Factory automatically injects the current restricted subnets into `data-existing-ids` on the input. |
|
||||
| `VALIDATION_IP_OR_DOMAIN_NAME` | IPv4 address or hostname/domain name. |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue