Skip to content

Commit f561fe0

Browse files
committed
fix #13
1 parent b026cf0 commit f561fe0

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

package.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,30 @@
4242
"node": ">=6"
4343
},
4444
"dependencies": {
45-
"deep-equal": "^1.0.1",
46-
"predicate": "^1.0.0",
47-
"selectn": "^1.1.2"
45+
"deep-equal": "1.0.1",
46+
"predicate": "1.2.0",
47+
"selectn": "1.1.2"
4848
},
4949
"devDependencies": {
5050
"atob": "^2.0.3",
51-
"babel-cli": "^6.24.1",
52-
"babel-core": "^6.25.0",
51+
"babel-cli": "^6.26.0",
52+
"babel-core": "^6.26.0",
5353
"babel-eslint": "^7.2.3",
5454
"babel-jest": "^20.0.3",
55-
"babel-loader": "^7.1.1",
55+
"babel-loader": "^7.1.2",
5656
"babel-plugin-transform-class-properties": "^6.24.1",
57-
"babel-polyfill": "^6.23.0",
57+
"babel-polyfill": "^6.26.0",
5858
"babel-preset-env": "^1.6.0",
5959
"babel-preset-es2015": "^6.24.1",
6060
"babel-preset-react": "^6.24.1",
61-
"babel-register": "^6.24.1",
62-
"codemirror": "^5.28.0",
61+
"babel-register": "^6.26.0",
62+
"codemirror": "^5.29.0",
6363
"coveralls": "^2.13.1",
6464
"cross-env": "^5.0.5",
65-
"css-loader": "^0.28.4",
66-
"eslint": "^4.4.1",
65+
"css-loader": "^0.28.7",
66+
"eslint": "^4.6.1",
6767
"eslint-plugin-jest": "^20.0.3",
68-
"eslint-plugin-react": "^7.1.0",
68+
"eslint-plugin-react": "^7.3.0",
6969
"eslint-plugin-standard": "^3.0.1",
7070
"exit-hook": "^1.1.1",
7171
"express": "^4.15.4",
@@ -75,14 +75,14 @@
7575
"html": "1.0.0",
7676
"husky": "^0.14.3",
7777
"jest": "^20.0.4",
78-
"jsdom": "^11.1.0",
79-
"lint-staged": "^4.0.3",
80-
"prettier": "^1.5.3",
81-
"regenerator-runtime": "^0.10.5",
78+
"jsdom": "^11.2.0",
79+
"lint-staged": "^4.1.0",
80+
"prettier": "^1.6.1",
81+
"regenerator-runtime": "^0.11.0",
8282
"rimraf": "^2.6.1",
83-
"sinon": "^3.1.0",
83+
"sinon": "^3.2.1",
8484
"style-loader": "^0.18.2",
85-
"webpack": "^3.5.1"
85+
"webpack": "^3.5.5"
8686
},
8787
"directories": {
8888
"test": "test"

src/validation.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,23 @@ export function listAllPredicates(conditions, schema) {
8080
return allPredicates.filter((v, i, a) => allPredicates.indexOf(v) === i);
8181
}
8282

83+
const UNSUPPORTED_PREDICATES = [
84+
"and",
85+
"or",
86+
"ternary",
87+
"every",
88+
"some",
89+
"curry",
90+
"partial",
91+
"complement",
92+
"mod",
93+
];
94+
8395
export function listInvalidPredicates(conditions, schema) {
8496
let refPredicates = listAllPredicates(conditions, schema);
85-
return refPredicates.filter(p => predicate[p] === undefined);
97+
return refPredicates.filter(
98+
p => UNSUPPORTED_PREDICATES.includes(p) || predicate[p] === undefined
99+
);
86100
}
87101

88102
export function validatePredicates(conditions, schema) {

test/predicate.test.js

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ test("work with empty", function() {
1212
expect(predicate.empty(null)).toBeTruthy();
1313
});
1414

15-
test("and is not predicate", () => {
16-
expect(predicate.and).toBeUndefined();
17-
});
18-
1915
predicate.range = predicate.curry((val, range) => {
2016
return (
2117
predicate.num(val) &&

test/validation.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ test("invalid field NOT or", () => {
181181
{
182182
conditions: {
183183
not: {
184-
firstName: "bad",
184+
firstName: "or",
185185
},
186186
},
187187
event: { type: "remove" },
188188
},
189189
]);
190190

191191
expect(listInvalidPredicates(invalidFieldNotWithOr, defSchema)).toEqual([
192-
"bad",
192+
"or",
193193
]);
194194
expect(() => validatePredicates(invalidFieldNotWithOr, defSchema)).toThrow();
195195
});

0 commit comments

Comments
 (0)