A Git oid field: 40 (SHA-1) or 64 (SHA-256) lowercase hex characters.
(value: Option<&str>)
| 296 | |
| 297 | /// A Git oid field: 40 (SHA-1) or 64 (SHA-256) lowercase hex characters. |
| 298 | fn validate_oid(value: Option<&str>) -> PristineResult<()> { |
| 299 | let Some(value) = value else { |
| 300 | return Ok(()); |
| 301 | }; |
| 302 | let valid_len = value.len() == 40 || value.len() == 64; |
| 303 | let hex = value.bytes().all(|b| b.is_ascii_hexdigit()) |
| 304 | && !value.bytes().any(|b| b.is_ascii_uppercase()); |
| 305 | if !valid_len || !hex { |
| 306 | return Err(PristineError::Serialization { |
| 307 | message: format!( |
| 308 | "ref mapping oid field is not a 40/64-character lowercase hex Git oid: {value:?}" |
| 309 | ), |
| 310 | }); |
| 311 | } |
| 312 | Ok(()) |
| 313 | } |
| 314 | |
| 315 | /// An Atomic state field: non-empty base32 (the Merkle's base32 encoding). |
| 316 | fn validate_state(value: Option<&str>) -> PristineResult<()> { |