Exemplo n.º 1
0
        protected bool CheckForValidationFailures(object instance, Type instanceType,
                                                  PropertyInfo prop, CompositeNode node,
                                                  string name, string prefix,
                                                  ErrorSummary summary)
        {
            object value = null;

            if (validator == null)
            {
                return(false);
            }

            IValidator[] validators = validator.GetValidators(instanceType, prop);

            if (validators.Length != 0)
            {
                Node valNode = node.GetChildNode(name);

                if (valNode != null && valNode.NodeType == NodeType.Leaf)
                {
                    value = ((LeafNode)valNode).Value;
                }

                if (value == null && IsDateTimeType(prop.PropertyType))
                {
                    bool conversionSucceeded;
                    value = TryGetDateWithUTCFormat(node, name, out conversionSucceeded);
                }

                if (value == null && valNode == null)
                {
                    // Value was not present on the data source. Skip validation
                    return(false);
                }
            }

            return(CheckForValidationFailures(instance, instanceType, prop, value, name, prefix, summary));
        }