Skip to content

Commit

Permalink
docs: fix some of the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
maritz committed May 31, 2018
1 parent 7104a0c commit 13151d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 6 additions & 3 deletions index.md
Expand Up @@ -6,7 +6,6 @@ layout: default
## Links

* [Github](https://github.com/maritz/nohm)
* [API docs](api/index.html)
* [v2 docs](index_v2.html)

## How To
Expand Down Expand Up @@ -344,7 +343,7 @@ var validatorModel = nohm.model('validatorModel', {
});
```

You can find the documentation of the [built-in validations in the api](api/symbols/validators.html) or look directly [at the source code](https://github.com/maritz/nohm/blob/master/lib/validators.js).
You can find the documentation of the built-in validations by looking directly [at the source code](https://github.com/maritz/nohm/blob/v1_maintenance/lib/validators.js).

##### Custom validations in extra files

Expand Down Expand Up @@ -476,7 +475,11 @@ user.p('name'); // returns 'test2'
user.p('email'); // returns 'someMail@example.com'
```

There are several other methods for dealing with properties: [allProperties](api/symbols/Nohm.html#.allProperties), [propertyReset](api/symbols/Nohm.html#.propertyReset), [propertyDiff](api/symbols/Nohm.html#.propertyDiff)
There are several other methods for dealing with properties:

* allProperties() - get an object with all properties plus it's id
* propertyReset([propertyName]) - Resets a property to its state as it was at last init/load/save (whichever was most recent - so for init it would be defaultValues)
* propertyDiff() - Returns an array of all the properties that have been changed since init/load/save (whichever was most recent - so for init it would be defaultValues)

### Validating

Expand Down
20 changes: 10 additions & 10 deletions index_v2.md
Expand Up @@ -397,8 +397,7 @@ const validatorModel = nohm.model('validatorModel', {
});
```

You can find the documentation of the [built-in validations in the api](api/symbols/validators.html) or look directly [at the source code](https://github.com/maritz/nohm/blob/master/lib/validators.js).
// TODO: decide what to do with this...
You can find the documentation of the built-in validations by looking directly [at the source code](https://github.com/maritz/nohm/blob/master/ts/universalValidators.js).

##### Custom validations in extra files

Expand Down Expand Up @@ -530,7 +529,11 @@ user.property('email'); // returns 'someMail@example.com'

The convenience short versions .p() and .prop() still exist, but are deprecated and cause a deprecation warning.

There are several other methods for dealing with properties: [allProperties](api/symbols/Nohm.html#.allProperties), [propertyReset](api/symbols/Nohm.html#.propertyReset), [propertyDiff](api/symbols/Nohm.html#.propertyDiff)
There are several other methods for dealing with properties:

* allProperties() - get an object with all properties plus it's id
* propertyReset([propertyName]) - Resets a property to its state as it was at last init/load/save (whichever was most recent - so for init it would be defaultValues)
* propertyDiff() - Returns an array of all the properties that have been changed since init/load/save (whichever was most recent - so for init it would be defaultValues)

### Validating

Expand Down Expand Up @@ -931,7 +934,7 @@ try {
success: boolean;
child: NohmModel;
parent: NohmModel;
error: null | Error;
error: null | Error | LinkError | ValidationError;
}
*/
} else if (err instanceof Nohm.ValidationError) {
Expand All @@ -955,16 +958,13 @@ This process works infinitely deep. However this process is not atomic, thus it
link can take an optional options object or link name as the second argument. If it is a string, it's assumed to be the link name.
The options object has 2 available options:

// TODO: fix the link options docs

```typescript
User1.link(ManagerRole, {
name: 'hasRole', // otherwise defaults to "default"
error: function(error_mesage, validation_errors, object) {
error: function(error, linkedInstance) {
// this is called if there was an error while saving the linked object (ManagerRole in this case)
// error_message is the error ManagerRole.save() reported
// validation_errors is ManagerRole.errors
// object is ManagerRole
// error is the error ManagerRole.save() rejected with
// linkedInstance is ManagerRole
},
});
```
Expand Down

0 comments on commit 13151d9

Please sign in to comment.