use nutype::nutype;
#[nutype(
sanitize(trim, lowercase),
validate(len_char_max = 63, regex = r"^[a-z_][a-z0-9_]*$"),
derive(
Debug,
Clone,
Display,
AsRef,
Deref,
Hash,
Eq,
PartialEq,
Ord,
PartialOrd,
Serialize,
Deserialize
)
)]
pub struct SinkName(String);
impl schemars::JsonSchema for SinkName {
fn schema_name() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Borrowed("SinkName")
}
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!({
"type": "string",
"pattern": "^[a-z_][a-z0-9_]*$",
"maxLength": 63,
"description": "A sink name: lowercase letters, digits, and underscores, not starting with a digit, at most 63 characters."
})
}
}