/// <summary>
        /// Creates the validator for the specified target and ruleset.
        /// </summary>
        /// <param name="targetType">The <see cref="Type"/>to validate.</param>
        /// <param name="ruleset">The ruleset to use when validating</param>
        /// <param name="mainValidatorFactory">Factory to use when building nested validators.</param>
        /// <returns>A <see cref="Validator"/></returns>
        protected internal override Validator InnerCreateValidator(
            Type targetType,
            string ruleset,
            ValidatorFactory mainValidatorFactory)
        {
            var builder =
                new MetadataValidatorBuilder(MemberAccessValidatorBuilderFactory.Default, mainValidatorFactory);

            return(builder.CreateValidator(targetType, ruleset));
        }
        public static Validator GetPropertyValidatorFromAttributes(Type type, PropertyInfo propertyInfo, string ruleset,
                                                                   MemberAccessValidatorBuilderFactory memberAccessValidatorBuilderFactory)
        {
            Validator validator = null;

            lock (AttributeOnlyPropertyValidatorsCache)
            {
                var key = new PropertyValidatorCacheKey(type, propertyInfo.Name, ruleset);
                if (!AttributeOnlyPropertyValidatorsCache.TryGetValue(key, out validator))
                {
                    validator = new MetadataValidatorBuilder(memberAccessValidatorBuilderFactory, ValidationFactory.DefaultCompositeValidatorFactory).CreateValidatorForProperty(propertyInfo, ruleset);

                    AttributeOnlyPropertyValidatorsCache[key] = validator;
                }
            }

            return(validator);
        }