src/Shared/EntityFramework/Core/SchemaObjectModel/ValidationHelper.cs
// <summary>
// Validates whether facets are declared correctly.
// </summary>
// <param name="element"> Schema element being validated. Must not be null. </param>
// <param name="type"> Resolved type (from declaration on the element). Possibly null. </param>
// <param name="typeUsageBuilder"> TypeUsageBuilder for the current element. Must not be null. </param>
Validates whether facets are declared correctly.
Validates whether facets are declared correctly .
internal static void ValidateFacets(SchemaElement element, SchemaType type, TypeUsageBuilder typeUsageBuilder)
        {
            DebugCheck.NotNull(element);
            DebugCheck.NotNull(typeUsageBuilder);
            if (type != null)
            {
                var schemaEnumType = type as SchemaEnumType;
                if (schemaEnumType != null)
                {
                    typeUsageBuilder.ValidateEnumFacets(schemaEnumType);
                }
                else if (!(type is ScalarType)
                         && typeUsageBuilder.HasUserDefinedFacets)
                {
                    element.AddError(
                        ErrorCode.FacetOnNonScalarType, EdmSchemaErrorSeverity.Error, Strings.FacetsOnNonScalarType(type.FQName));
                }
            }
            else
            {
                if (typeUsageBuilder.HasUserDefinedFacets)
                {
                    element.AddError(
                        ErrorCode.IncorrectlyPlacedFacet, EdmSchemaErrorSeverity.Error, Strings.FacetDeclarationRequiresTypeAttribute);
                }
            }
        }
internal static void ValidateFacets ( SchemaElement element , SchemaType type , TypeUsageBuilder typeUsageBuilder ) { DebugCheck . NotNull ( element ) ; DebugCheck . NotNull ( typeUsageBuilder ) ; if ( type != null ) { var schemaEnumType = type as SchemaEnumType ; if ( schemaEnumType != null ) { typeUsageBuilder . ValidateEnumFacets ( schemaEnumType ) ; } else if ( ! ( type is ScalarType ) && typeUsageBuilder . HasUserDefinedFacets ) { element . AddError ( ErrorCode . FacetOnNonScalarType , EdmSchemaErrorSeverity . Error , Strings . FacetsOnNonScalarType ( type . FQName ) ) ; } } else { if ( typeUsageBuilder . HasUserDefinedFacets ) { element . AddError ( ErrorCode . IncorrectlyPlacedFacet , EdmSchemaErrorSeverity . Error , Strings . FacetDeclarationRequiresTypeAttribute ) ; } } }
Validates whether facets are declared correctly.
Validates whether facets are declared correctly .
// Non-scalar type should not have Facets.  // Type attribute not specified but facets exist.
element
SchemaElement
Schema element being validated. Must not be null.
Schema element being validated . Must not be null .
type
SchemaType
Resolved type (from declaration on the element). Possibly null.
Resolved type ( from declaration on the element ) . Possibly null .
typeUsageBuilder
TypeUsageBuilder
TypeUsageBuilder for the current element. Must not be null.
TypeUsageBuilder for the current element . Must not be null .