BusinessLogic.Models.Games.Validation.PlayerRankValidationAttribute.IsValid C# (CSharp) Method

IsValid() protected method

protected IsValid ( object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : System.ComponentModel.DataAnnotations.ValidationResult
value object
validationContext System.ComponentModel.DataAnnotations.ValidationContext
return System.ComponentModel.DataAnnotations.ValidationResult
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var playerRanks = (value as IEnumerable<IPlayerRank>).ToList();

            try
            {
                PlayerRankValidator.ValidatePlayerRanks(playerRanks);

                return ValidationResult.Success;
            }catch(ArgumentException argumentException)
            {
                return new ValidationResult(argumentException.Message);
            }
        }
    }
PlayerRankValidationAttribute