Example #1
0
        /// <summary>
        /// Validates the DTO fields
        /// </summary>
        /// <returns>true when validation succeeds</returns>
        public void Validate()
        {
            if (!Firstname.HasValue())
            {
                throw new InvalidPropertyValueException(nameof(Firstname), Firstname);
            }

            if (!Surname.HasValue())
            {
                throw new InvalidPropertyValueException(nameof(Surname), Surname);
            }

            if (!Email.IsEmailAddress())
            {
                throw new InvalidPropertyValueException(nameof(Email), Email);
            }

            if (!Contact.IsContactNumber())
            {
                throw new InvalidPropertyValueException(nameof(Contact), Contact);
            }

            if (DOB == null)
            {
                throw new InvalidPropertyValueException(nameof(DOB));
            }
        }