ParseID creates a new [ID] from a string If a validation error occurs, it returns nil and the error. Rules: - Components separated by '/' - Each component is non-empty - Only characters A-Z, a-z, 0-9, '.', '_', '-' or ':' - No leading, trailing, or double slashes
(s string)
| 159 | // - Only characters A-Z, a-z, 0-9, '.', '_', '-' or ':' |
| 160 | // - No leading, trailing, or double slashes |
| 161 | func ParseID(s string) (ID, error) { |
| 162 | if err := valid(s); err != nil { |
| 163 | return nil, err |
| 164 | } |
| 165 | |
| 166 | return id(s), nil |
| 167 | } |
| 168 | |
| 169 | // MustParseID parses a string into a [ID] and behaves similar to |
| 170 | // [ParseID], however, it panics when the id is invalid |