File tree Expand file tree Collapse file tree 6 files changed +28
-15
lines changed
Expand file tree Collapse file tree 6 files changed +28
-15
lines changed Original file line number Diff line number Diff line change 11aldeed:collection2-core@1.0.0
2- aldeed:schema-deny@1.0.1
2+ aldeed:schema-deny@1.1.0
33aldeed:simple-schema@1.5.3
44babel-compiler@5.8.24_1
55babel-runtime@0.1.4
@@ -24,7 +24,7 @@ html-tools@1.0.5
2424htmljs@1.0.5
2525id-map@1.0.4
2626jquery@1.11.4
27- local-test:aldeed:schema-deny@1.0.1
27+ local-test:aldeed:schema-deny@1.1.0
2828logging@1.0.8
2929mdg:validation-error@0.2.0
3030meteor@1.1.10
Original file line number Diff line number Diff line change 11# Change Log
22
3+ # 1.1.0
4+
5+ Support for SimpleSchema 2.0
6+
37# 1.0.0
48
59Initial release. Originally included in the aldeed: collection2 package.
Original file line number Diff line number Diff line change 11The MIT License (MIT)
22
3- Copyright (c) 2015 Eric Dobbertin
3+ Copyright (c) 2015-2016 Eric Dobbertin
44
55Permission is hereby granted, free of charge, to any person obtaining a copy of
66this software and associated documentation files (the "Software"), to deal in
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ $ meteor add aldeed:schema-deny
1818If 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
Original file line number Diff line number Diff 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
1315Collection2 . 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} ) ;
Original file line number Diff line number Diff line change 11Package . 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
You can’t perform that action at this time.
0 commit comments