Ejemplo n.º 1
0
        /// <summary>
        ///     Validates a complex property.
        /// </summary>
        /// <param name="entityValidationContext"> Validation context. Never null. </param>
        /// <param name="property"> Property to validate. Never null. </param>
        /// <returns>
        ///     Validation errors as <see cref="IEnumerable{EntityValidationError}" /> . Empty if no errors. Never null.
        /// </returns>
        public override IEnumerable <EntityValidationError> Validate(
            EntityValidationContext entityValidationContext, InternalValidateProperty property)
        {
            DebugCheck.NotNull(property);

            var validationErrors = new List <EntityValidationError>();

            validationErrors.AddRange(base.Validate(entityValidationContext, property));

            // don't drill into complex types if there were errors or the complex property has not been initialized at all
            if (!validationErrors.Any() &&
                property.PropertyValue != null
                &&
                _complexTypeValidator != null)
            {
                validationErrors.AddRange(
                    _complexTypeValidator.Validate(entityValidationContext, property));
            }

            return(validationErrors);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Validates an instance.
 /// </summary>
 /// <param name="entityValidationContext"> Entity validation context. Must not be null. </param>
 /// <param name="property"> The entry for the complex property. Null if validating an entity. </param>
 /// <returns>
 ///     <see cref="DbEntityValidationResult" /> instance. Never null.
 /// </returns>
 public new IEnumerable <EntityValidationError> Validate(
     EntityValidationContext entityValidationContext, InternalValidateProperty property)
 {
     return(base.Validate(entityValidationContext, property));
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Validates type properties. Any validation errors will be added to <paramref name="validationErrors" />
 ///     collection.
 /// </summary>
 /// <param name="entityValidationContext"> Validation context. Must not be null. </param>
 /// <param name="parentProperty"> The entry for the complex property. Null if validating an entity. </param>
 /// <param name="validationErrors"> Collection of validation errors. Any validation errors will be added to it. </param>
 /// <remarks>
 ///     Note that <paramref name="validationErrors" /> will be modified by this method. Errors should be only added,
 ///     never removed or changed. Taking a collection as a modifiable parameter saves a couple of memory allocations
 ///     and a merge of validation error lists per entity.
 /// </remarks>
 protected abstract void ValidateProperties(
     EntityValidationContext entityValidationContext, InternalValidateProperty parentProperty,
     List <EntityValidationError> validationErrors);