Пример #1
0
        public static Schema Dispatch(FieldAdded @event, Schema schema, FieldRegistry registry)
        {
            var partitioning =
                string.Equals(@event.Partitioning, Partitioning.Language.Key, StringComparison.OrdinalIgnoreCase) ?
                Partitioning.Language :
                Partitioning.Invariant;

            return(schema.AddOrUpdateField(registry.CreateField(@event.FieldId.Id, @event.Name, partitioning, @event.Properties)));
        }
Пример #2
0
        public async Task Should_add_error_if_validating_data_with_invalid_field()
        {
            schema = schema.AddOrUpdateField(new NumberField(1, "my-field", Partitioning.Invariant, new NumberFieldProperties {
                MaxValue = 100
            }));

            var data =
                new NamedContentData()
                .AddField("my-field",
                          new ContentFieldData()
                          .SetValue(1000));

            await data.ValidateAsync(context, schema, languagesConfig.ToResolver(), errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("my-field must be less than '100'", "my-field")
            });
        }
Пример #3
0
 public static Schema Dispatch(FieldAdded @event, Schema schema, FieldRegistry registry)
 {
     return(schema.AddOrUpdateField(registry.CreateField(@event.FieldId.Id, @event.Name, @event.Properties)));
 }