Exemple #1
0
        internal static bool ValidateProperties(this ISchema schema, out Exception exception)
        {
            if (schema.Properties == null)
            {
                exception = new SchemaValidationException($"Properties field is required for schema objects ({schema.Slug})");
                return(false);
            }

            foreach (var fieldInfo in schema.Properties)
            {
                if (!fieldInfo.ValidateSchema(out exception))
                {
                    return(false);
                }
            }

            schema.CheckPropertiesUniqueness(out exception);

            var uniqueProperties = schema.GetUniqueProperties();

            foreach (var uniqueProperty in uniqueProperties)
            {
                if (uniqueProperty.IsAnArrayItem(out _))
                {
                    exception = new SchemaValidationException($"The unique constraints could not use in arrays. Use the 'uniqueBy' feature instead of. ('{uniqueProperty.Name}')");

                    return(false);
                }
            }

            return(exception == null);
        }