- Source
Namespaces
Methods
compile(code) → {Array}
Compile a validator expression string into an internal stack representation.
| Name | Type | Description |
|---|---|---|
code | string | Validator expression string (e.g. |
- Source
Compiled token stack used by validators.
- Type:
- Array
create(field, type, optional, vfunc) → {Validator}
Compile a validator expression string into an internal stack representation.
| Name | Type | Description |
|---|---|---|
field | string | field name |
type | string | validator type |
optional | boolean | whether the field is optional |
vfunc | string | a validator function |
- Source
Compiled token stack used by validators.
- Type:
- Validator
parseDecimal(x) → {number}
Parse a decimal number string. Returns NaN when not a valid number.
| Name | Type | Description |
|---|---|---|
x | string |
- Source
Decimal number or NaN
- Type:
- number
parseIPv4(x) → {Array.<number>|null}
Parse IPv4 address into an array of 4 octets or return null on failure.
| Name | Type | Description |
|---|---|---|
x | string | IPv4 address string |
- Source
Array of 4 octets or null.
- Type:
- Array.<number> |
null
parseIPv6(x) → {Array.<number>|null}
Parse IPv6 address into an array of 8 16-bit words or return null on failure. Supports IPv4-embedded IPv6 (::ffff:a.b.c.d) and zero-compression.
| Name | Type | Description |
|---|---|---|
x | string | IPv6 address string |
- Source
Array of 8 16-bit words or null.
- Type:
- Array.<number> |
null
parseInteger(x) → {number}
Parse an integer string. Returns NaN when not a valid integer.
| Name | Type | Description |
|---|---|---|
x | string |
- Source
Integer or NaN
- Type:
- number