/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (AccountNumber == null) { throw new ValidationException(ValidationRules.CannotBeNull, "AccountNumber"); } if (RoutingNumber == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RoutingNumber"); } if (AccountHolderName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "AccountHolderName"); } if (AccountHolderAddress == null) { throw new ValidationException(ValidationRules.CannotBeNull, "AccountHolderAddress"); } if (Type == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Type"); } if (Email == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Email"); } if (AccountNumber != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(AccountNumber, "\\d{4,17}$")) { throw new ValidationException(ValidationRules.Pattern, "AccountNumber", "\\d{4,17}$"); } } if (RoutingNumber != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(RoutingNumber, "\\d{9,9}$")) { throw new ValidationException(ValidationRules.Pattern, "RoutingNumber", "\\d{9,9}$"); } } if (AccountHolderAddress != null) { AccountHolderAddress.Validate(); } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (AccountHolderName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "AccountHolderName"); } if (AccountHolderAddress == null) { throw new ValidationException(ValidationRules.CannotBeNull, "AccountHolderAddress"); } if (Email == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Email"); } if (AccountHolderAddress != null) { AccountHolderAddress.Validate(); } }