Skip to content

Commit f85384d

Browse files
committed
fork: use NPM [email protected] as base
1 parent ed90e93 commit f85384d

File tree

75 files changed

+14542
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+14542
-0
lines changed

lib/SimpleSchema.js

Lines changed: 1140 additions & 0 deletions
Large diffs are not rendered by default.

lib/SimpleSchema.tests.js

Lines changed: 1139 additions & 0 deletions
Large diffs are not rendered by default.

lib/SimpleSchemaGroup.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import MongoObject from 'mongo-object';
2+
3+
class SimpleSchemaGroup {
4+
constructor(...definitions) {
5+
this.definitions = definitions.map((definition) => {
6+
if (MongoObject.isBasicObject(definition)) {
7+
return { ...definition };
8+
}
9+
10+
if (definition instanceof RegExp) {
11+
return {
12+
type: String,
13+
regEx: definition,
14+
};
15+
}
16+
17+
return { type: definition };
18+
});
19+
}
20+
21+
get singleType() {
22+
return this.definitions[0].type;
23+
}
24+
25+
clone() {
26+
return new SimpleSchemaGroup(...this.definitions);
27+
}
28+
29+
extend(otherGroup) {
30+
// We extend based on index being the same. No better way I can think of at the moment.
31+
this.definitions = this.definitions.map((def, index) => {
32+
const otherDef = otherGroup.definitions[index];
33+
if (!otherDef) return def;
34+
return { ...def, ...otherDef };
35+
});
36+
}
37+
}
38+
39+
export default SimpleSchemaGroup;

0 commit comments

Comments
 (0)