Example #1
0
        /// <summary>Initializes a new instance of the <see cref="EndpointValidatorComponent{T}"/> class.</summary>
        /// <param name="continuation">The continuation.</param>
        /// <param name="order">The order.</param>
        public EndpointValidatorComponent(ValidationContinuation continuation = ValidationContinuation.OnlyIfValid, int order = 0)
        {
            this.Order = order < 0
                ? 0
                : order;

            this.Continuation = continuation;
        }
Example #2
0
        /// <summary>Initializes a new instance of the <see cref="ApiEndpointValidationAttribute"/> class.</summary>
        /// <param name="validatorType">Type of the validator.</param>
        /// <param name="continuation">The continuation.</param>
        /// <param name="order">The order.</param>
        /// <exception cref="ArgumentNullException">validatorType</exception>
        /// <exception cref="ArgumentException"></exception>
        public ApiEndpointValidationAttribute(
            Type validatorType,
            ValidationContinuation continuation = ValidationContinuation.OnlyIfValid,
            int order = 0)
        {
            if (validatorType == null)
            {
                throw new ArgumentNullException(nameof(validatorType));
            }

            if (validatorType.GetInterface(nameof(IEndpointValidator), false) == null)
            {
                throw new ArgumentException($"{nameof(validatorType)} must implement interface {typeof(IEndpointValidator).AssemblyQualifiedName}");
            }

            this.ValidatorType = validatorType;
            this.Continuation  = continuation;

            this.Order = order < 0
                ? 0
                : order;
        }
Example #3
0
 /// <summary>Initializes a new instance of the <see cref="DataAnnotationsValidationProvider"/> class.</summary>
 /// <param name="continuation">The continuation.</param>
 /// <param name="validateAllProperties">if set to <c>true</c> [validate all properties].</param>
 public DataAnnotationsValidationProvider(ValidationContinuation continuation = ValidationContinuation.OnlyIfValid, bool validateAllProperties = true)
 {
     this.Continuation          = continuation;
     this.ValidateAllProperties = validateAllProperties;
 }