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
  • Coverage
  • 96.77%
    90 out of 93 items documented0 out of 2 items with examples
  • Size
  • Source code size: 73.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 847.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 29s Average build duration of successful builds.
  • all releases: 29s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • appwrite/appwrite
    58629 5921 295
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • loks0n

utopia-validators

The checks of utopia-php/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.

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")));