You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+2
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,8 @@ Always fork the repo and create your branch from master. If you've added code th
37
37
38
38
Please follow the [TypeScript coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines).
39
39
40
+
You should prefix all private variables with `_` sign. To prevent accidental name collisions with your code Rawmodel somes prefixes names of public objects with `$` and names of private objects with `$$`. You can find this convention in outer frameworks like [AngularJS](https://docs.angularjs.org/api).
41
+
40
42
## Release process
41
43
42
44
The release manager will publish packages to NPM using these commands.
Copy file name to clipboardExpand all lines: README.md
+51-51
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,7 @@ import { stringParser } from '@rawmodel/parsers';
73
73
74
74
classUserextendsModel {
75
75
@prop({
76
-
parse: {
76
+
parser: {
77
77
resolver: stringParser(),
78
78
},
79
79
})
@@ -102,13 +102,13 @@ class Friend extends Model {
102
102
103
103
classUserextendsModel {
104
104
@prop({
105
-
parse: {
105
+
parser: {
106
106
resolver: Address,
107
107
},
108
108
})
109
109
public address:Address;
110
110
@prop({
111
-
parse: {
111
+
parser: {
112
112
array: true,
113
113
resolver: Friend,
114
114
},
@@ -162,15 +162,15 @@ A property can have a custom `getter` and a custom `setter`. This function share
162
162
163
163
```ts
164
164
@prop({
165
-
get(value) { returnvalue },
166
-
set(value) { returnvalue },
165
+
getter(value) { returnvalue },
166
+
setter(value) { returnvalue },
167
167
})
168
168
publicname: string;
169
169
```
170
170
171
171
### Value Assignments
172
172
173
-
Model's properties are like properties on a Javascript Object. We can easily assign a value to a property through its setter method (e.g. `model.name = 'value';`). Instead of assigning properties one by one, we can use the `populate()` method as shown below.
173
+
Model's properties are like properties of a Javascript Object. We can easily assign a value to a property through its setter method (e.g. `model.name = 'value';`). Instead of assigning properties one by one, we can use the `populate()` method to assign values to multiple enumerable properties.
174
174
175
175
```ts
176
176
model.populate({
@@ -213,7 +213,7 @@ It's encouraged to use the `populate()` method for assigning values unless you k
213
213
214
214
### Serialization & Filtering
215
215
216
-
Model provides useful methods for object serialization and filtering. All properties are serializable by default and are thus included in the result object returned by the `serialize()` method. We can customize the output and include or exclude properties for different situations by using serialization strategies.
216
+
Model provides useful methods for object serialization and filtering. All enumerable properties are serializable by default and are thus included in the result object returned by the `serialize()` method. We can customize the output and include or exclude properties for different situations by using serialization strategies.
217
217
218
218
```ts
219
219
classUserextendsModel {
@@ -272,7 +272,7 @@ RawModel provides a simple mechanism for validating properties. All validators s
272
272
```ts
273
273
classUserextendsModel {
274
274
@prop({
275
-
validate: [ // property validation setup
275
+
validators: [ // property validation setup
276
276
{ // validator recipe
277
277
resolver(v) { return!!v }, // [required] validator function
278
278
code: 422, // [optional] error code
@@ -295,7 +295,7 @@ RawModel provides a mechanism for handling property-related errors. The logic is
295
295
```ts
296
296
classUserextendsModel {
297
297
@prop({
298
-
handle: [ // property error handling setup
298
+
handlers: [ // property error handling setup
299
299
{ // handler recipe
300
300
resolver(e) { returne.message==='foo' }, // [required] error resolve function
301
301
code: 31000, // [optional] error code
@@ -366,7 +366,7 @@ const schema = {
366
366
props: [ // schema properties
367
367
{ // property definition
368
368
name: 'title', // property name
369
-
validate: [
369
+
validators: [
370
370
{
371
371
resolver: 'stringLength', // validator resolver name
0 commit comments