| 132 | } |
| 133 | |
| 134 | fn validate_email(email: &str) -> ModelValidatorResult<UserError> { |
| 135 | if (email.len() < User::EMAIL_LEN_RANGE.0 as usize) |
| 136 | || (email.len() > User::EMAIL_LEN_RANGE.1 as usize) |
| 137 | { |
| 138 | return Err(UserError::ValidationError { |
| 139 | info: format!( |
| 140 | "Email length must be between {} and {}", |
| 141 | User::EMAIL_LEN_RANGE.0, |
| 142 | User::EMAIL_LEN_RANGE.1, |
| 143 | ), |
| 144 | }); |
| 145 | } |
| 146 | if let Err(e) = EmailAddress::from_str(email) { |
| 147 | return Err(UserError::ValidationError { |
| 148 | info: format!("Email validation failed: {e}",), |
| 149 | }); |
| 150 | } |
| 151 | |
| 152 | Ok(()) |
| 153 | } |
| 154 | |
| 155 | fn validate_stations(stations: &[UserStation]) -> ModelValidatorResult<UserError> { |
| 156 | if stations.len() > User::MAX_STATIONS as usize { |