๐Ÿ€ ATproto library for gleam
atproto library gleam
34

Configure Feed

Select the types of activity you want to include in your feed.

possum/did: add documentation for `did.parse`

kacaii.dev (Jul 1, 2026, 2:13 PM -0300) 9b9d167b c664c10f

+18 -3
+18 -3
src/possum/did.gleam
··· 13 13 import gleam/regexp 14 14 import gleam/result 15 15 16 - const pattern = "^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$" 16 + pub const pattern = "^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$" 17 17 18 18 pub type DidError { 19 19 InvalidRegexPattern(pattern: String) ··· 46 46 47 47 /// Return the DID identifier. 48 48 /// 49 - /// This function does convert the value to a valid DID format, for that 50 - /// use `to_string`. 49 + /// This function **does not** convert the value into a valid DID format, 50 + /// for that use `to_string`. 51 51 /// 52 52 /// ## Examples 53 53 /// 54 54 /// ```gleam 55 + /// import possum/did 56 + /// 55 57 /// let identifier = 56 58 /// Did(Plc, "k5vecqzf4d5mdvkcu3mx6l5g") 57 59 /// |> did.identifier ··· 67 69 /// ## Examples 68 70 /// 69 71 /// ```gleam 72 + /// import possum/did 73 + /// 70 74 /// let string = 71 75 /// Did(Plc, "k5vecqzf4d5mdvkcu3mx6l5g") 72 76 /// |> did.to_string ··· 111 115 Web 112 116 } 113 117 118 + /// Parse a string into a valid `Did` type 119 + /// If the value is not a valid string then an error is returned. 120 + /// 121 + /// ## Examples 122 + /// 123 + /// ```gleam 124 + /// import possum/did 125 + /// 126 + /// let string = "did:plc:k5vecqzf4d5mdvkcu3mx6l5g" 127 + /// let assert Ok(did) = did.parse(string) 128 + /// ``` 114 129 pub fn parse(content: String) -> Result(Did, DidError) { 115 130 use with <- result.try( 116 131 regexp.from_string(pattern)