/// <summary>
        /// Creates the validator.
        /// </summary>
        /// <param name="targetType">The type of the target element.</param>
        /// <returns>The validator object.</returns>
        /// <exception cref="ArgumentException">Thrown if the target element does not support <see cref="IComparable"/></exception>
        protected override Validator DoCreateValidator(
            Type targetType)
        {
            if (targetType == null)
            {
                throw new ArgumentNullException(nameof(targetType));
            }

            return(new PositiveValidator(
                       ValidatorsConstants.GetZero(targetType),
                       GetMessageTemplate(),
                       Negated));
        }
Example #2
0
        /// <summary>
        /// Creates the validator.
        /// </summary>
        /// <param name="targetType">The type of the target element.</param>
        /// <returns>The created validator.</returns>
        /// <exception cref="ArgumentException">Thrown if the target does not support <see cref="IComparable"/></exception>
        protected override Validator DoCreateValidator(Type targetType)
        {
            if (targetType == null)
            {
                throw new ArgumentNullException(nameof(targetType));
            }

            var zero = ValidatorsConstants.GetZero(targetType);

            return(new NonnegativeValidator(
                       zero,
                       GetMessageTemplate(),
                       Tag,
                       Negated));
        }