rsamec / business-rules-engine

Business rules engine
Other
92 stars 15 forks source link

Enhancement: We should be able to split JSON Schema Validation input into templates residing in separate files- #7

Open SameerSiddiqui opened 8 years ago

SameerSiddiqui commented 8 years ago

So i use file system to maintain json templates.

I notice that we can introduce a feature where can split the JSON Schema into small reusable chunks and then create a final JSON Schema Validation object... using lodash _.assign

we can introduce assign key

So let's say we have firstName and lastName section common between lots of different Schemes. I should be able to write this template outside and using nodeJS require i should be able to assign this template to my final JSON Schema validation.

var nameTemplate = {
        FirstName: {
            type: "string",
            title: "First name",
            required: "true",
            maxLength: 15
        },
        LastName: {
            type: "string",
            "title": "Last name",
            required: true,
            maxLength: 15
        }
}

so final JSON Schema will become somthing like this-

assign:[{
nameTemplate,
Contacts: {
            type: "array",
            maxItems: 4,......
}]

This will make the JSON Schema's to share the templates and we don't have to redefine the templates again and again.

Let me know if it makes sense and i can create a PR.

Thanks, Sameer