Skip to main content

validate

Function validate 

Source
pub fn validate(target: &str, error: ErrorKind) -> Result<()>
Expand description

If the specified target is valid to use as an MXP identifier or value, returns Ok(()). Otherwise, returns an mxp::Error for the target with the specified error kind.

ยงExamples

let err = mxp::ErrorKind::InvalidEntityName;
assert!(mxp::validate("abc", err).is_ok());
assert!(mxp::validate("aBc_-.", err).is_ok());
assert!(mxp::validate("", err).is_err());
assert!(mxp::validate("_test", err).is_err());
assert!(mxp::validate("abc!", err).is_err());