Skip to content

Commit 279ebf3

Browse files
committed
Update for SimpleSchema 2.0 and publish 1.1.0
1 parent c757bf4 commit 279ebf3

File tree

6 files changed

+28
-15
lines changed

6 files changed

+28
-15
lines changed

.versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
aldeed:collection2-core@1.0.0
2-
aldeed:schema-deny@1.0.1
2+
aldeed:schema-deny@1.1.0
33
aldeed:simple-schema@1.5.3
44
babel-compiler@5.8.24_1
55
babel-runtime@0.1.4
@@ -24,7 +24,7 @@ html-tools@1.0.5
2424
htmljs@1.0.5
2525
id-map@1.0.4
2626
jquery@1.11.4
27-
local-test:aldeed:schema-deny@1.0.1
27+
local-test:aldeed:schema-deny@1.1.0
2828
logging@1.0.8
2929
mdg:validation-error@0.2.0
3030
meteor@1.1.10

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
# 1.1.0
4+
5+
Support for SimpleSchema 2.0
6+
37
# 1.0.0
48

59
Initial release. Originally included in the aldeed:collection2 package.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Eric Dobbertin
3+
Copyright (c) 2015-2016 Eric Dobbertin
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ meteor add aldeed:schema-deny
1818
If you set `denyUpdate: true`, any collection update that modifies the field will fail. For instance:
1919

2020
```js
21-
var PostSchema = new SimpleSchema({
21+
const postSchema = new SimpleSchema({
2222
title: {
2323
type: String
2424
},
@@ -31,13 +31,13 @@ var PostSchema = new SimpleSchema({
3131
}
3232
});
3333

34-
Posts = new Mongo.Collection('posts');
35-
Posts.attachSchema(PostSchema);
34+
const Posts = new Mongo.Collection('posts');
35+
Posts.attachSchema(postSchema);
3636

37-
var postId = Posts.insert({title: 'Hello', content: 'World', createdAt: new Date()});
37+
const postId = Posts.insert({title: 'Hello', content: 'World', createdAt: new Date()});
3838
```
3939

40-
The `denyInsert` option works the same way, but for inserts. If you set `denyInsert` to true, you will need to set `optional: true` as well.
40+
The `denyInsert` option works the same way, but for inserts. If you set `denyInsert` to true, you will need to set `optional: true` as well.
4141

4242
## Contributing
4343

lib/deny.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ SimpleSchema.extendOptions({
55
});
66

77
// Define validation error messages
8-
SimpleSchema.messages({
9-
insertNotAllowed: "[label] cannot be set during an insert",
10-
updateNotAllowed: "[label] cannot be set during an update"
11-
});
8+
if (!SimpleSchema.version || SimpleSchema.version < 2) {
9+
SimpleSchema.messages({
10+
insertNotAllowed: '[label] cannot be set during an insert',
11+
updateNotAllowed: '[label] cannot be set during an update'
12+
});
13+
}
1214

1315
Collection2.on('schema.attached', function (collection, ss) {
16+
if (ss.version >= 2) {
17+
ss.messageBox.messages({
18+
insertNotAllowed: '{{label}} cannot be set during an insert',
19+
updateNotAllowed: '{{label}} cannot be set during an update'
20+
});
21+
}
22+
1423
ss.addValidator(function() {
1524
if (!this.isSet) return;
1625

1726
var def = this.definition;
1827

19-
if (def.denyInsert && this.isInsert) return "insertNotAllowed";
20-
if (def.denyUpdate && (this.isUpdate || this.isUpsert)) return "updateNotAllowed";
28+
if (def.denyInsert && this.isInsert) return 'insertNotAllowed';
29+
if (def.denyUpdate && (this.isUpdate || this.isUpsert)) return 'updateNotAllowed';
2130
});
2231
});

package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package.describe({
22
name: "aldeed:schema-deny",
33
summary: "Deny inserting or updating certain properties through schema options",
4-
version: "1.0.1",
4+
version: "1.1.0",
55
git: "https://github.com/aldeed/meteor-schema-deny.git"
66
});
77

0 commit comments

Comments
 (0)