示例#1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            CompositionViewModel formData = validationContext.ObjectInstance as CompositionViewModel;

            if (formData == null)
            {
                return(ValidationResult.Success);
            }

            int minPitch = (int)formData.MinPitch;
            int maxPitch = (int)formData.MaxPitch;

            if (CompositionContext.IsPitchRangeValid(minPitch, maxPitch, out string errorMessage))
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult(errorMessage));
            }
        }