Skip to main content

cimvalidation/
helpers.rs

1
2/// Returns true if the string is a valid xsd:dateTime value.
3pub fn is_xsd_datetime(s: &str) -> bool {
4    // ISO 8601: YYYY-MM-DDTHH:MM:SS or with timezone
5    let s = s.trim();
6    if s.len() < 19 { return false; }
7    s.as_bytes().get(4) == Some(&b'-')
8        && s.as_bytes().get(7) == Some(&b'-')
9        && s.as_bytes().get(10) == Some(&b'T')
10}
11
12/// Returns true if the string is a valid xsd:date value.
13pub fn is_xsd_date(s: &str) -> bool {
14    let s = s.trim();
15    s.len() >= 10
16        && s.as_bytes().get(4) == Some(&b'-')
17        && s.as_bytes().get(7) == Some(&b'-')
18}
19
20/// Returns true if the string is a valid xsd:gMonthDay value (--MM-DD).
21pub fn is_xsd_gmonthday(s: &str) -> bool {
22    let s = s.trim();
23    s.len() >= 7 && s.starts_with("--")
24}
25
26/// Returns true if the string is a non-empty anyURI (basic check).
27pub fn is_xsd_anyuri(s: &str) -> bool {
28    !s.trim().is_empty()
29}