MCPcopy Create free account
hub / github.com/dfinity/orbit / validate_email

Function validate_email

core/control-panel/impl/src/models/user.rs:134–153  ·  view source on GitHub ↗
(email: &str)

Source from the content-addressed store, hash-verified

132}
133
134fn 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
155fn validate_stations(stations: &[UserStation]) -> ModelValidatorResult<UserError> {
156 if stations.len() > User::MAX_STATIONS as usize {

Callers 1

validateMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected