tjwebb / congruence

Validate the structure of Javascript objects using semantic templates. Written as a lodash mixin.
https://npmjs.org/package/congruence
8 stars 1 forks source link

congruence and xtuple-query #9

Closed bryzettler closed 9 years ago

bryzettler commented 9 years ago

Hey, TJ

Looking through your congruence/xtuple-query code and trying to do something similar. I noticed xtuple-query uses an older version of congruence that has an "or" function to support using an array as a predicate. That was removed in this commit.

I'm wanting to use the latest version of congruence but can't quite figure out how you replaced the "or" method. From what I can tell you didn't, and you expect the user to write their own "or" predicate. Is this assumption correct or am I missing something?

A good example of what I am trying to achieve is something similar to this template.

tjwebb commented 9 years ago

Between 1.5.x and 1.6.x I removed a lot of complexity, which included that custom syntax, and the _.or function. You can implement the same thing just using lodash _.any: https://lodash.com/docs#some, or using the built-in _.similar.

I'll add some examples to the unit tests.

tjwebb commented 9 years ago

Does this example help?

https://github.com/tjwebb/congruence/blob/master/test.js#L396-L418

bryzettler commented 9 years ago

Yea, helped a lot. Thanks for the quick reply.