misc edits in /docs; mostly style, grammar, consistency (#489)

* misc edits in /docs; mostly style, grammar, consistency

* changes per reviewers requests

* removed .md ext from links in 2 files per request
This commit is contained in:
Rich Cook
2017-07-26 22:29:29 -05:00
committed by Jessica Parsons
parent b283f6931f
commit 6ad6bfd094
10 changed files with 83 additions and 89 deletions

View File

@ -1,6 +1,6 @@
# Collection Field Validation
## Available validations to use on config.yaml:
## Available validations to use on `config.yml`:
- Presence: By default all widgets are required, unless specified in the config. Example:
`- {label: "Subtitle", name: "subtitle", widget: "string", required: false}`
@ -9,7 +9,7 @@
`- {label: "Title", name: "title", widget: "string", pattern: [".{10,}", "Should have more than 10 characters"] }`
## Advanced Guide (For widget authors).
## Advanced Guide (For widget authors)
The widget control can optionally implement an `isValid` method to perform custom validations, in addition to presence and pattern. The `isValid` method will be automatically called, and it can return either a boolean value, an object with an error message or a promise. Examples:
@ -32,7 +32,7 @@ Existing error:
};
```
**Object with `error` (Useful for returning custom error messages)**
**Object with `error` (useful for returning custom error messages)**
Existing error:
```javascript
@ -43,7 +43,7 @@ Existing error:
```
**Promise**
You can also return a promise from isValid. While the promise is pending, the widget will be marked as in error. When the promise resolves, the error is automatically cleared.
You can also return a promise from `isValid`. While the promise is pending, the widget will be marked as "in error". When the promise resolves, the error is automatically cleared.
```javascript
isValid = () => {
@ -51,4 +51,4 @@ You can also return a promise from isValid. While the promise is pending, the wi
};
```
Note: Do not create a promise inside isValid - isValid is called right before trying to persist. This means that even if a previous promise was already resolved, when the user hits 'save', `isValid` will be called again - if it returns a new Promise it will be immediately marked as in error until the new promise resolves.
Note: Do not create a promise inside `isValid` - `isValid` is called right before trying to persist. This means that even if a previous promise was already resolved, when the user hits 'save', `isValid` will be called again. If it returns a new promise, it will be immediately marked as "in error" until the new promise resolves.