hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Personal-info newtypes shared by every account role — student, teacher, |
| 2 | //! manager, and admin records all carry the same optional contact fields. |
| 3 | |
| 4 | use crate; |
| 5 | use crateBadgeStats; |
| 6 | use crateTimestamp; |
| 7 | use crateValidationError; |
| 8 | use crate; |
| 9 | |
| 10 | /// A person's given or family name. One type serves both fields — the `field` |
| 11 | /// tag only steers the error message ("name …" vs "surname …"). Stored trimmed; |
| 12 | /// unicode is welcome (names are not ASCII). |
| 13 | |
| 14 | |
| 15 | ; |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | /// A plausibly-shaped email address (see [`validate_email`]). Stored trimmed. |
| 29 | |
| 30 | |
| 31 | ; |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | /// A phone number: optional leading `+`, 7–15 digits, cosmetic separators |
| 45 | /// allowed (see [`validate_phone`]). Stored trimmed, separators kept as given. |
| 46 | |
| 47 | |
| 48 | ; |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | /// A birth date, canonicalized to `YYYY-MM-DD`. Construction parses the input |
| 62 | /// as a real calendar date (no 2026-02-30) and refuses future dates. |
| 63 | /// |
| 64 | /// "Future" is judged against UTC **plus one day of grace**: a birth date is a |
| 65 | /// calendar date on the writer's wall, and a client ahead of UTC (up to |
| 66 | /// UTC+14) legitimately submits a date the server's UTC calendar hasn't |
| 67 | /// reached yet. Without the grace, "born today" entered from Istanbul or |
| 68 | /// Auckland shortly after local midnight is wrongly rejected. |
| 69 | |
| 70 | |
| 71 | ; |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | /// The name a profile shows instead of the legal one — a nickname, a shortened |
| 99 | /// form, whatever the person answers to. Stored trimmed; unicode is welcome, |
| 100 | /// same as [`PersonName`] and unlike the ASCII-only username. |
| 101 | |
| 102 | |
| 103 | ; |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | /// A short self-description on the public profile. Free text within |
| 117 | /// [`MAX_BIO_LEN`], blank allowed — an empty bio is a written-then-erased one, |
| 118 | /// which is a legitimate state and not an error. Stored trimmed. |
| 119 | |
| 120 | |
| 121 | ; |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | /// A person's gender, self-declared and deliberately coarse — the school |
| 135 | /// office needs a word for a form, not an identity system. One of four fixed |
| 136 | /// wire values (`female`, `male`, `other`, `undisclosed`), stored as the same |
| 137 | /// string; `NULL` (never chosen) is a row state, not a fifth value. |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | pub const GENDERS: = |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | ; |
| 178 | |
| 179 | /// A postal address, [`MAX_ADDRESS_LEN`] characters at most. Free text on |
| 180 | /// purpose — addresses do not fit a shape the way a phone number does, and |
| 181 | /// enforcing one would only reject real ones. Stored trimmed. |
| 182 | |
| 183 | |
| 184 | ; |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | /// The motivational counters on a public profile. Every field is a derived |
| 198 | /// count, never a settable one: zero rows is a true zero, so these are `i64` |
| 199 | /// and never `Option` — a `null` in this API means "never chose", which a |
| 200 | /// derived number can't be. An account that predates the feature therefore |
| 201 | /// reads exactly like a fresh one. |
| 202 | /// |
| 203 | /// One named struct on purpose: the auto-earned badge rules take a whole |
| 204 | /// `ProfileStats` as their sole input, so a counter added here reaches them |
| 205 | /// without touching a signature. |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 |