Skip to main content

validate_with

Function validate_with 

Source
pub fn validate_with(input: &[u8], allowed: Class) -> Result<(), ParseError>
Expand description

As validate, and every byte other than a %XX triple is in allowed.

validate_with(target, Class::URI_TARGET) checks the characters of a request target.

§Errors

ErrorKind::InvalidPercentEncoding; a control kind for a control byte; ErrorKind::InvalidByte for another byte outside allowed.

§Examples

use parse_net::{pct::validate_with, class::Class, ErrorKind};

assert!(validate_with(b"/a/b?c=d&e=%20", Class::URI_TARGET).is_ok());
assert_eq!(validate_with(b"/a#frag", Class::URI_TARGET).unwrap_err().kind(), ErrorKind::InvalidByte);