Function validate_identifier

Source
pub fn validate_identifier<F: FnOnce(String) -> PrincipalError>(
    id: &str,
    prefix: &str,
    map_err: F,
) -> Result<(), PrincipalError>
Expand description

Verify that an instance profile id, group id, role id, or user id meets AWS requirements.

AWS only stipulates the first four characters of the ID as a type identifier; however, all IDs follow a common convention of being 20+ character base-32 strings. We enforce the prefix, length, and base-32 requirements here.

If identifier meets these requirements, Ok is returned. Otherwise, Err(map_err(id.to_string())) is returned.