rsamec / business-rules-engine Goto Github PK
View Code? Open in Web Editor NEWBusiness rules engine
License: Other
Business rules engine
License: Other
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
I tried to build the project from source, however I ran into a couple of issues.
The first one was the underscore package was looking for a version no longer available, so I modified it from "underscore": "1.0.6", to "underscore": "^1.0.6",
the second issue, there were some missing required packages in the devDependencies section
"coffee-script": "^1.6.3",
"grunt-contrib-coffee": "^0.10.1",
"grunt-coffeelint": "0.0.8"
Once I made those changes, I was able to issue the grunt test command, but that threw a missing file error.
Cannot resolve referenced file: '../../typings/business-rules-engine/business-rules-engine.d.ts'.
Looks like the type script files for the project are missing from source control. Would it be possible for you to check those into git?
Thanks
rick
It says here https://www.npmjs.com/package/business-rules-engine
That is it MIT.
But when I look at the LICENSE in the repository it does not say MIT...
โฆ but this PR is slightly incomplete as it doesn't have tests. This is because I can not get the project to build / test / install typings.
I get only awful lot of Typescript related errors, like these when running grunt typings
:
>> error TS1005: ',' expected.
>> /Users/me/projects/business-rules-engine/typings/underscore/underscore.d.ts(6033,42):
>> error TS1005: ';' expected.
>> /Users/me/projects/business-rules-engine/typings/underscore/underscore.d.ts(6033,53):
>> error TS1003: Identifier expected.
>> /Users/me/projects/business-rules-engine/typings/underscore/underscore.d.ts(6042,14):
>> error TS1005: ',' expected.
>> /Users/me/projects/business-rules-engine/typings/underscore/underscore.d.ts(6042,32):
>> error TS1005: ',' expected.
>> /Users/me/projects/business-rules-engine/typings/underscore/underscore.d.ts(6042,42):
Can it be related to this issue DefinitelyTyped/DefinitelyTyped#4004 ?
I have trouble understanding how to use different translations in my app, I know this is more of a question (which generally should go to StackOverflow), but I think README.md
should have an example of using localization.
Let's say I have the following setup:
const FormSchema = require('business-rules-engine/commonjs/FormSchema');
const schema = {
foo: {
type: 'string',
minLength: 100,
required: true,
title: 'Foo',
},
}
const validator = new FormSchema.JsonSchemaRuleFactory(schema).CreateRule('foo');
const result = validator.Validate({ foo: 'not long enough' });
console.log(result.ErrorMessage);
Considering that example code, how would one go and specify that in which language the messages result.ErrorMessage
are displayed?
I was trying to use the default RangeValidator but ran into an issue where it was always returning false
it('should return false when value is not in range', inject(function( ) {
var range = [5,11]
var validatorMin = new Validators.RangeValidator(range);
expect(validatorMin.isAcceptable(4)).toBeFalsy();
}));
I looked at the source for the range validator and found it was trying to use length for the comparison
if (!_.isNumber(s))
s = parseFloat(s);
return s.length >= this.Min && s.length <= this.Max;
I think it should have been return s >= this.Min && s <= this.Max;
once i changed this line, the test started passing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.