Skip to content

Commit b9a05cf

Browse files
authored
Merge pull request #55 from xpepermint/master
Update dependencies
2 parents 8c8e225 + 3fa0bbe commit b9a05cf

28 files changed

Lines changed: 905 additions & 671 deletions

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ Please follow the [TypeScript coding guidelines](https://github.com/Microsoft/Ty
4141

4242
The release manager will publish packages to NPM using these commands.
4343

44-
```sh
44+
```
4545
$ rush version --bump --override-bump minor
46+
$ rush update --full
47+
$ rush rebuild
48+
$ rush test
4649
$ rush publish --publish --include-all
4750
```

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class User extends Model {
106106

107107
We can set a `defaultValue` for each property which will automatically populate a property on creation.
108108

109-
The `defaultValue` can also be a method which returns a dynamic value. This function shares the context of a property instance thus you have access to all the features of the `Prop` class.
109+
The `defaultValue` can also be a method which returns a dynamic value. This function shares the context of the associated model.
110110

111111
```ts
112112
@prop({
@@ -119,7 +119,7 @@ now: string;
119119

120120
Similar to default values, we can set a `fakeValue` for each property, to populate a property with fakes data when calling the `fake()` method.
121121

122-
The `fakeValue` can also be a method which returns a dynamic value. This function shares the context of a property instance, thus you have access to all the features of the `Prop` class.
122+
The `fakeValue` can also be a method which returns a dynamic value. This function shares the context of the associated model.
123123

124124
```ts
125125
@prop({
@@ -132,18 +132,18 @@ today: string;
132132

133133
By default, all defined properties are set to `null`. Similar to default and fake value we can set an `emptyValue` option for each property, to automatically replace `null` values.
134134

135-
The `emptyValue` can also be a method which returns a dynamic value. Note that this function shares the context of a property instance, thus you have access to all the features of the `Prop` class.
135+
The `emptyValue` can also be a method which returns a dynamic value. This function shares the context of the associated model.
136136

137137
```ts
138138
@prop({
139-
fakeValue() { return '' },
139+
emptyValue() { return '' },
140140
})
141141
name: string;
142142
```
143143

144144
### Prop Value Transformation
145145

146-
A property can have a custom `getter` and a custom `setter`. These methods all share the context of a property instance, thus you have access to all the features of the `Prop` class.
146+
A property can have a custom `getter` and a custom `setter`. This function shares the context of the associated model.
147147

148148
```ts
149149
@prop({
@@ -250,14 +250,14 @@ Note that the `commit` method will memorize a serialized data and the `rollback`
250250

251251
### Validation
252252

253-
RawModel provides a simple mechanism for validating properties.
253+
RawModel provides a simple mechanism for validating properties. Validators shares the context of the associated model.
254254

255255
```ts
256256
class User extends Model {
257257
@prop({
258258
validate: [ // property validation setup
259259
{ // validator recipe
260-
handler: (v) => !!v, // [required] validator function
260+
handler(v) { return !!v }, // [required] validator function
261261
code: 422, // [optional] error code
262262
condition() { return true }, // [optional] condition which switches the validation on/off
263263
},
@@ -274,14 +274,14 @@ user.validate().catch((err) => {
274274

275275
### Error Handling
276276

277-
RawModel provides a mechanism for handling property-related errors. The logic is aligned with the validation thus the validation and the error handling can easily be managed in a unified way. This is great because we always deal with validation errors and can thus directly send these errors back to a user in a unified format.
277+
RawModel provides a mechanism for handling property-related errors. The logic is aligned with the validation thus the validation and the error handling can easily be managed in a unified way. This is great because we always deal with validation errors and can thus directly send these errors back to a user in a unified format. Handlers shares the context of the associated model.
278278

279279
```ts
280280
class User extends Model {
281281
@prop({
282282
handle: [ // property error handling setup
283283
{ // handler recipe
284-
handler: (e) => e.message === 'foo', // [required] errir handler function
284+
handler(e) { return e.message === 'foo' }, // [required] errir handler function
285285
code: 422, // [optional] error code
286286
condition() { return true }, // [optional] condition which switches the handling on/off
287287
},

0 commit comments

Comments
 (0)