///<summary> /// Initializes a composite validator factory from attribute and configuration validator factories ///</summary> ///<param name="instrumentationProvider">The <see cref="IValidationInstrumentationProvider"/> to use when instrumenting validators.</param> ///<param name="attributeValidatorFactory">The <see cref="AttributeValidatorFactory"/> to composite.</param> ///<param name="configurationValidatorFactory">The <see cref="ConfigurationValidatorFactory"/> to composite.</param> public CompositeValidatorFactory( IValidationInstrumentationProvider instrumentationProvider, AttributeValidatorFactory attributeValidatorFactory, ConfigurationValidatorFactory configurationValidatorFactory) : this(instrumentationProvider, new ValidatorFactory[] { attributeValidatorFactory, configurationValidatorFactory }) { }
///<summary> /// Initializes a composite validator factory from attribute and configuration validator factories ///</summary> ///<param name="attributeValidatorFactory">The <see cref="AttributeValidatorFactory"/> to composite.</param> ///<param name="configurationValidatorFactory">The <see cref="ConfigurationValidatorFactory"/> to composite.</param> ///<param name="validationAttributeValidatorFactory">The <see cref="ValidationAttributeValidatorFactory"/> to composite.</param> public CompositeValidatorFactory( AttributeValidatorFactory attributeValidatorFactory, ConfigurationValidatorFactory configurationValidatorFactory, ValidationAttributeValidatorFactory validationAttributeValidatorFactory) : this(new ValidatorFactory[] { attributeValidatorFactory, configurationValidatorFactory, validationAttributeValidatorFactory }) { }
/// <summary> /// Sets the default configuration validator factory for the static <see cref="ValidationFactory"/>. /// </summary> /// <param name="factory">The configuration validation factory.</param> public static void SetDefaultConfigurationValidatorFactory(ConfigurationValidatorFactory factory) { Guard.ArgumentNotNull(factory, "factory"); defaultConfigurationValidatorFactory = factory; defaultCompositeValidatorFactory = BuildDefaultCompositeValidatorFactory(); }
/// <summary> /// Returns a validator representing the validation criteria specified for type <paramref name="targetType"/> /// through configuration for the supplied ruleset /// retrieving configuration information from the supplied <see cref="IConfigurationSource"/>. /// </summary> /// <param name="targetType">The type to get the validator for.</param> /// <param name="ruleset">The name of the required ruleset.</param> /// <param name="configurationSource">The configuration source from where configuration information is to be retrieved.</param> /// <returns>The validator.</returns> /// <exception cref="ArgumentNullException">when the <paramref name="ruleset"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException">when the <paramref name="configurationSource"/> is <see langword="null"/>.</exception> public static Validator CreateValidatorFromConfiguration(Type targetType, string ruleset, IConfigurationSource configurationSource) { var validationFactory = ConfigurationValidatorFactory.FromConfigurationSource(configurationSource); return(validationFactory.CreateValidator(targetType, ruleset)); }
/// <summary> /// Returns a validator representing the validation criteria specified for type <typeparamref name="T"/> /// through configuration for the supplied ruleset /// retrieving configuration information from the supplied <see cref="IConfigurationSource"/>. /// </summary> /// <typeparam name="T">The type to get the validator for.</typeparam> /// <param name="ruleset">The name of the required ruleset.</param> /// <param name="configurationSource">The configuration source from where configuration information is to be retrieved.</param> /// <returns>The validator.</returns> /// <exception cref="ArgumentNullException">when the <paramref name="ruleset"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException">when the <paramref name="configurationSource"/> is <see langword="null"/>.</exception> public static Validator <T> CreateValidatorFromConfiguration <T>(string ruleset, IConfigurationSource configurationSource) { var validationFactory = ConfigurationValidatorFactory.FromConfigurationSource(configurationSource); return(validationFactory.CreateValidator <T>(ruleset)); }