コード例 #1
0
        public void QuasiSchema7IfFalseElseFalse()
        {
            JsonSchemaFactory.RegisterExtendedSchema(QuasiSchema7.MetaQuasi.Id, () => new QuasiSchema7(), QuasiSchema7.MetaQuasi);
            JsonSchemaPropertyValidatorFactory.RegisterValidator(new QuasiSchema7IfThenElseValidator());

            var schema = new QuasiSchema7
            {
                Schema = QuasiSchema7.MetaQuasi.Id,
                If     = new QuasiSchema7 {
                    Type = JsonSchemaType.Integer
                },
                Then = JsonSchema06.False,
                Else = new QuasiSchema7 {
                    Type = JsonSchemaType.String
                }
            };

            JsonValue json = false;

            var results = schema.Validate(json);

            results.AssertInvalid();

            json = QuasiSchema7.MetaQuasi.ToJson(new JsonSerializer());

            Console.WriteLine(json.GetIndentedString());
        }
コード例 #2
0
        public void QuasiSchema7IfTrueThenTrue()
        {
            JsonSchemaFactory.RegisterExtendedSchema(QuasiSchema7.MetaQuasi.Id, () => new QuasiSchema7(), QuasiSchema7.MetaQuasi);
            JsonSchemaPropertyValidatorFactory.RegisterValidator(new QuasiSchema7IfThenElseValidator());

            var schema = new QuasiSchema7
            {
                Schema = QuasiSchema7.MetaQuasi.Id,
                If     = new QuasiSchema7 {
                    Type = JsonSchemaType.Integer
                },
                Then = new QuasiSchema7 {
                    Minimum = 10
                },
                Else = JsonSchema06.False
            };

            JsonValue json = 15;

            var results = schema.Validate(json);

            results.AssertValid();
        }