Skip to main content

validation_help

Function validation_help 

Source
pub fn validation_help<T: KeyDomain>() -> Option<&'static str>
Expand description

Get validation help text for a domain

Returns the help text provided by the domain’s validation_help method, if any. This can be useful for providing user-friendly error messages.

§Examples

use domain_key::{Domain, KeyDomain, validation};

#[derive(Debug)]
struct TestDomain;
impl Domain for TestDomain {
    const DOMAIN_NAME: &'static str = "test";
}
impl KeyDomain for TestDomain {
    fn validation_help() -> Option<&'static str> {
        Some("Keys must be alphanumeric with underscores")
    }
}

if let Some(help) = validation::validation_help::<TestDomain>() {
    println!("Validation help: {}", help);
}