MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / validate_state

Function validate_state

atomic-core/src/pristine/ref_mapping.rs:316–332  ·  view source on GitHub ↗

An Atomic state field: non-empty base32 (the Merkle's base32 encoding).

(value: Option<&str>)

Source from the content-addressed store, hash-verified

314
315/// An Atomic state field: non-empty base32 (the Merkle's base32 encoding).
316fn validate_state(value: Option<&str>) -> PristineResult<()> {
317 let Some(value) = value else {
318 return Ok(());
319 };
320 let base32 = !value.is_empty()
321 && value
322 .bytes()
323 .all(|b| b.is_ascii_uppercase() || (b'2'..=b'7').contains(&b));
324 if !base32 {
325 return Err(PristineError::Serialization {
326 message: format!(
327 "ref mapping state field is not non-empty uppercase base32: {value:?}"
328 ),
329 });
330 }
331 Ok(())
332}
333
334/// A mapped ref name: well-formed Git reference name under `refs/`
335/// (git-check-ref-format's exclusions, simplified to the durable subset).

Callers 2

encodeMethod · 0.85
decodeMethod · 0.85

Calls 4

is_emptyMethod · 0.45
allMethod · 0.45
bytesMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected