macro_rules! regex_is_valid {
    ($regex:expr) => { ... };
    ($regex:expr, $fn_name:ident) => { ... };
}
Expand description

This macro takes a string that contains a regular expression will construct a new validity predicate that may be used by the is_valid_newstring macro. An optional second parameter provides a name for the new predicate function, overriding the default is_valid.

The generated function uses lazy_static to only compile the regular expression once. You will require a dependency on both the lazy_static and regex crates, as you see in the example below.

Example


regex_is_valid!(r"[0-9]+", is_valid_integer);