Beispiel #1
0
        /// <summary>
        ///   Validates the specified target.
        /// </summary>
        ///
        /// <param name="target">The target to be validated.</param>
        /// <param name="ruleNames">The names of validation rule sets to run in addition to the default ruleset.</param>
        ///
        /// <returns>A set of <see cref="Error"/> instances that correspond to validation failures; if the <paramref name="target"/> is valid, the set will be empty.</returns>
        ///
        public async Task <IEnumerable <Error> > ValidateAsync(T target,
                                                               params string[] ruleNames)
        {
            ValidationResult result;

            if (target != null)
            {
                result = await this.ValidateAsync(target, ruleSet : ValidatorBase <T> .BuildRuleSets(ruleNames)).ConfigureAwait(false);
            }
            else
            {
                result = ValidatorBase <T> .NullTargetResult;
            }

            return(ValidatorBase <T> .TransformValidationResult(result));
        }
Beispiel #2
0
        /// <summary>
        ///   Validates the specified target.
        /// </summary>
        ///
        /// <param name="target">The target to be validated.</param>
        /// <param name="ruleNames">The names of validation rule sets to run in addition to the default ruleset.</param>
        ///
        /// <returns>A set of <see cref="Error"/> instances that correspond to validation failures; if the <paramref name="target"/> is valid, the set will be empty.</returns>
        ///
        public IEnumerable <Error> Validate(T target,
                                            params string[] ruleNames)
        {
            ValidationResult result;

            if (target != null)
            {
                result = this.Validate(target, ruleSet: ValidatorBase <T> .BuildRuleSets(ruleNames));
            }
            else
            {
                result = ValidatorBase <T> .NullTargetResult;
            }

            return(ValidatorBase <T> .TransformValidationResult(result));
        }