utopia-validators 0.1.0

The checks of Utopia's request validators: booleans, integers, floats, numbers, ranges, ports, hex colors, text, identifiers, white lists, substrings, DNS labels, hostnames, domains, hosts, IP addresses, URLs, phone numbers, JSON, FCM service accounts, globstar patterns and the validators that compose others.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# utopia-validators

The checks of [`utopia-php/validators`](../../../packages/validators) as PHP runs them: booleans,
integers, floats, numbers, ranges, ports, hex colors, text, identifiers, white lists, substrings,
DNS labels, hostnames, domains, hosts, IP addresses, URLs and phone numbers (over `php-std`'s ports of
`filter_var()`, `parse_url()` and `Uri\Rfc3986\Uri`). Each function is the body of a PHP
validator's method, over a value as PHP sees it (`Input`), with the same coercions
(`is_numeric()`, `$value + 0`), comparisons and messages. The validator classes, and the state
their constructors keep, live in the PHP extension (`crates/extension`), which passes it in.

```rust
use utopia_validators::{Input, Integer, Number, range};

let int8 = Integer::new(8, false).unwrap();
assert!(int8.accepts(true, Input::Str(b" 127 ")));
assert!(!int8.accepts(true, Input::Float(1.0)));
assert!(range(Number::Int(1), Number::Int(10), b"integer", Input::Str(b"5")));
```