public virtual void Validate(
     ActionContext actionContext,
     ValidationStateDictionary?validationState,
     string?prefix,
     object?model,
     ModelMetadata metadata)
 => Validate(actionContext, validationState, prefix, model, metadata, container: null);
Exemplo n.º 2
0
        public ValidationVisitor(
            ActionContext actionContext,
            IModelValidatorProvider validatorProvider,
            ValidatorCache validatorCache,
            IModelMetadataProvider metadataProvider,
            ValidationStateDictionary?validationState)
        {
            if (actionContext == null)
            {
                throw new ArgumentNullException(nameof(actionContext));
            }

            if (validatorProvider == null)
            {
                throw new ArgumentNullException(nameof(validatorProvider));
            }

            if (validatorCache == null)
            {
                throw new ArgumentNullException(nameof(validatorCache));
            }

            Context           = actionContext;
            ValidatorProvider = validatorProvider;
            Cache             = validatorCache;

            MetadataProvider = metadataProvider;
            ValidationState  = validationState;

            ModelState   = actionContext.ModelState;
            _currentPath = new ValidationStack();
        }
    public virtual void Validate(
        ActionContext actionContext,
        ValidationStateDictionary?validationState,
        string?prefix,
        object?model,
        ModelMetadata metadata,
        object?container)
    {
        var visitor = GetValidationVisitor(
            actionContext,
            _validatorProvider,
            _validatorCache,
            _modelMetadataProvider,
            validationState);

        visitor.Validate(metadata, prefix, model, alwaysValidateAtTopLevel: metadata.IsRequired, container);
    }
    public virtual void Validate(
        ActionContext actionContext,
        ValidationStateDictionary?validationState,
        string?prefix,
        object?model)
    {
        var visitor = GetValidationVisitor(
            actionContext,
            _validatorProvider,
            _validatorCache,
            _modelMetadataProvider,
            validationState);

        var metadata = model == null ? null : _modelMetadataProvider.GetMetadataForType(model.GetType());

        visitor.Validate(metadata, prefix, model, alwaysValidateAtTopLevel: false);
    }
Exemplo n.º 5
0
    public override ValidationVisitor GetValidationVisitor(
        ActionContext actionContext,
        IModelValidatorProvider validatorProvider,
        ValidatorCache validatorCache,
        IModelMetadataProvider metadataProvider,
        ValidationStateDictionary?validationState)
    {
        var visitor = new ValidationVisitor(
            actionContext,
            validatorProvider,
            validatorCache,
            metadataProvider,
            validationState)
        {
            MaxValidationDepth = _mvcOptions.MaxValidationDepth,
            ValidateComplexTypesIfChildValidationFails = _mvcOptions.ValidateComplexTypesIfChildValidationFails,
        };

        return(visitor);
    }
 public abstract ValidationVisitor GetValidationVisitor(
     ActionContext actionContext,
     IModelValidatorProvider validatorProvider,
     ValidatorCache validatorCache,
     IModelMetadataProvider metadataProvider,
     ValidationStateDictionary?validationState);
 public void Validate(ActionContext actionContext,
                      ValidationStateDictionary?validationState, string prefix, object?model)
 {
 }