MCPcopy Create free account
hub / github.com/base/base / valid_id

Method valid_id

acceptance/src/report.rs:623–631  ·  view source on GitHub ↗

Validates a bounded portable record identifier.

(kind: &str, value: &str)

Source from the content-addressed store, hash-verified

621
622 /// Validates a bounded portable record identifier.
623 pub fn valid_id(kind: &str, value: &str) -> Result<()> {
624 if value.is_empty()
625 || value.len() > 200
626 || !value.bytes().all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.'))
627 {
628 bail!("invalid {kind} id {value:?}");
629 }
630 Ok(())
631 }
632
633 /// Rejects a string exceeding its byte budget.
634 pub fn bounded(name: &str, value: &str, maximum: usize) -> Result<()> {

Callers

nothing calls this directly

Calls 4

is_emptyMethod · 0.45
lenMethod · 0.45
allMethod · 0.45
bytesMethod · 0.45

Tested by

no test coverage detected