Beispiel #1
0
// Validate ...
// TODO: unify somehow, to have centralized place where email (or any other field) is validated
func (prr *PasswordRecoveryRequest) Validate(builder *lib.ValidationErrorBuilder) {
	if !validator.IsByteLength(prr.Email, 6, 45) {
		builder.Add("email", "validation_error.email_min_max_wrong")
	} else if !validator.IsEmail(prr.Email) {
		builder.Add("email", "Invalid email address.")
	}
}
Beispiel #2
0
// Validate ...
func (lr *LoginRequest) Validate(builder *lib.ValidationErrorBuilder) {
	if !validator.IsByteLength(lr.Email, 1, 255) {
		builder.Add("email", "Email address is missing.")
	}

	if !validator.IsByteLength(lr.Password, 1, 255) {
		builder.Add("password", "Password is missing.")
	}
}
Beispiel #3
0
// Validate ...
func (rr *RegistrationRequest) Validate(builder *lib.ValidationErrorBuilder) {
	if !validator.IsByteLength(rr.Email, 6, 45) {
		builder.Add("email", "validation_error.email_min_max_wrong")
	} else if !validator.IsEmail(rr.Email) {
		builder.Add("email", "Invalid email address.")
	}

	if !validator.IsByteLength(rr.Password, 6, 45) {
		builder.Add("password", "validation_error.password_min_max_wrong")
	}

	if !validator.IsByteLength(rr.FirstName, 1, 45) {
		builder.Add("firstName", "validation_error.firstname_max_len_wrong")
	}

	if !validator.IsByteLength(rr.LastName, 1, 45) {
		builder.Add("lastName", "validation_error.lastname_max_len_wrong")
	}
}