0
JSchema schema = new JSchema();
        schema.Type = JSchemaType.Object;
        schema.AllowAdditionalProperties = true;

        schema.Required.Add("Gender");
        schema.Required.Add("Single Girl Child");
        schema.Properties.Add("Gender",
           new JSchema()
           {
               Type = JSchemaType.String,
               AnyOf = {
                new JSchema{
                    Title = "MALE",
                    Pattern = GeneratePattern("male")
                    },
                new JSchema{
                    Title = "FEMALE",
                    Pattern =GeneratePattern("female")
                    },
                new JSchema{
                    Title = "THIRD GENDER",
                    Pattern =GeneratePattern("third gender")
                    }
               }
           }
       );
        schema.Properties.Add("Single Girl Child",
            new JSchema()
            {
                Type = JSchemaType.String,
                AnyOf = {
                new JSchema{
                    Title = "Yes",
                    Pattern = GeneratePattern("Yes")
                    },
                new JSchema{
                    Title = "No",
                    Pattern =GeneratePattern("No")
                    }
                }
            }
        );
        return schema.ToString();

The Above code creates Json Schema. I need to add IF condition on "SINGLE GIRL CHILD" property wherein if YES then the "GENDER" should be FEMALE.

I need to validate if Single Girl Child is YES then Gender show be Female. I need the syntax to create conditional JSchema.

0 Answers0