Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit bb050aa

Browse files
committed
Fixing docs formatting
1 parent 7b8ef36 commit bb050aa

File tree

7 files changed

+56
-50
lines changed

7 files changed

+56
-50
lines changed

docs/api/Control.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% raw %}
12
# Control Component
23

34
**Prop Types**
@@ -91,7 +92,7 @@ export default createStore(combineForms({
9192
It can also be a function that returns a string model. See [the documentation on tracking](../guides/tracking.md) for more information.
9293

9394
<h2 id="prop-mapProps"></h2>
94-
## `mapProps={\{...}}`
95+
## `mapProps={{...}}`
9596
_(Object | Function)_: A custom mapping from props provided by `Control` to props received by the component. Can be:
9697

9798
- An object, where each value is a function from original props to corresponding value in result props.
@@ -100,7 +101,7 @@ _(Object | Function)_: A custom mapping from props provided by `Control` to prop
100101
Examples:
101102
```jsx
102103
<Control
103-
mapProps={\{
104+
mapProps={{
104105
customChange: (props) => props.change,
105106
}}
106107
model="..."
@@ -129,15 +130,15 @@ You can also specify `updateOn={['change', 'blur']}` as an array of one or more
129130
- Use the `changeAction` prop if you want to dispatch custom actions along with the `actions.change(...)` action.
130131

131132
<h2 id="prop-validators"></h2>
132-
## `validators={\{...}}`
133+
## `validators={{...}}`
133134
_(Object)_: A map where the keys are validation keys, and the values are the corresponding functions that determine the validity of each key, given the model's value.
134135

135136
For example, this control validates that a username exists and is longer than 4 characters:
136137

137138
```jsx
138139
<Control.text
139140
model="user.username"
140-
validators={\{
141+
validators={{
141142
required: (val) => val.length,
142143
length: (val) => val.length > 4
143144
}}
@@ -153,7 +154,7 @@ const length = (val) => val.length > 8;
153154

154155
<Control.text
155156
model="user.username"
156-
validators={\{ required, length }}
157+
validators={{ required, length }}
157158
/>
158159
```
159160

@@ -169,7 +170,7 @@ _(String | Array)_: A string/array of strings specifying when validation should
169170
- To avoid displaying error messages on load (as controls might be invalid), use the `.pristine` property of the control when conditionally showing error messages, or use the `<Errors>` component.
170171

171172
<h2 id="prop-asyncValidators"></h2>
172-
## `asyncValidators={\{...}}`
173+
## `asyncValidators={{...}}`
173174
_(Object)_: A map where the keys are validation keys, and the values are the corresponding functions that (asynchronously) determine the validity of each key, given the model's value.
174175

175176
Each async validator function is called with 2 arguments:
@@ -183,7 +184,7 @@ For example, this control validates that a username is available via a promise:
183184
import isAvailable from '../path/to/is-available';
184185

185186
<Control.text model="user.username"
186-
asyncValidators={\{
187+
asyncValidators={{
187188
isAvailable: (value, done) => {
188189
isAvailable(value)
189190
.then((result) => done(result));
@@ -202,7 +203,7 @@ _(String | Array)_: A string/array of strings specifying when async validation s
202203
- `"focus"` - validate on the `onFocus` event handler
203204

204205
<h2 id="prop-errors"></h2>
205-
## `errors={\{...}}`
206+
## `errors={{...}}`
206207
_(Object)_: A map where the keys are error keys, and the values are the corresponding error validator functions that determine the invalidity of each key, given the model's value.
207208

208209
An **error validator** is a function that returns `true` or a truthy value (such as a string) if invalid, and `false` if valid.
@@ -212,7 +213,7 @@ For example, this control validates that a username exists and is longer than 4
212213
```jsx
213214
<Control.text
214215
model="user.username"
215-
errors={\{
216+
errors={{
216217
isEmpty: (val) => !val.length,
217218
tooLong: (val) => val.length > 16,
218219
}}
@@ -281,7 +282,7 @@ function changeAndSubmit(model, value) {
281282
- Since `changeAction` expects an action creator and `redux-thunk` is used, you can asynchronously dispatch actions (like the example above).
282283

283284
<h2 id="prop-controlProps"></h2>
284-
## `controlProps={\{...}}`
285+
## `controlProps={{...}}`
285286
_(Object)_: A mapping of control-specific props that will be applied directly to the rendered control. In some cases, this can be a safer way of applying props, especially if there are naming conflicts between `<Control>`-specific props (such as `"model"`) and props that need to go on the rendered control (e.g., `<input {...props} />`).
286287

287288
The normal behavior is that any extraneous props on `<Control>` that are not part of `Control.propTypes` (which are documented here) will be given to the rendered input.
@@ -293,7 +294,7 @@ Example:
293294
<Control.text
294295
model="..."
295296
component={CustomInput}
296-
controlProps={\{errors: 'errors for CustomInput'}}
297+
controlProps={{errors: 'errors for CustomInput'}}
297298
/>
298299
```
299300

@@ -336,7 +337,7 @@ However, in `<Control>`, it can be a boolean, or a function, string, or object a
336337
// Disable the submit button when the form is invalid
337338
<Control.button
338339
model="user"
339-
disabled={\{ valid: false }}
340+
disabled={{ valid: false }}
340341
>
341342
Submit!
342343
</Control.button>
@@ -345,7 +346,7 @@ However, in `<Control>`, it can be a boolean, or a function, string, or object a
345346
For example:
346347
- `disabled={true}` or `disabled={false}` will disable or enable the control respectively, as will any other primitive value, such as `undefined`, `null`, or a number
347348
- `disabled="touched"` will disable if the field is `touched` (works with any property on the field)
348-
- `disabled={\{ valid: false, touched: true }}` will disable if the field is both `touched` and not `valid`
349+
- `disabled={{ valid: false, touched: true }}` will disable if the field is both `touched` and not `valid`
349350
- `disabled={(fieldValue) => !fieldValue.valid}` will call the function provided with the `fieldValue` to determine its `disabled` state.
350351

351352
(since: version 1.3.0)
@@ -371,7 +372,7 @@ _(Boolean)_: Signifies that the field state (validation, etc.) should not persis
371372
// even when the control is unmounted.
372373
<Control.text
373374
model="user.name"
374-
validators={\{ length: (value) => value.length > 8 }}
375+
validators={{ length: (value) => value.length > 8 }}
375376
persist
376377
/>
377378
```
@@ -398,3 +399,4 @@ For `<Control.checkbox />`, the default `getValue` function is:
398399
_(Boolean)_: Signifies that the control is a toggle (e.g., a checkbox or a radio). If `true`, then some optimizations are made.
399400

400401
Default: `true` for `<Control.radio>` and `<Control.checkbox>`, `false` for all other controls.
402+
{% endraw %}

docs/api/Errors.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% raw %}
12
# Errors Component
23

34
## `<Errors />`
@@ -9,12 +10,12 @@ The `<Errors />` component provides a handy way of displaying form errors for a
910
<Control.text
1011
type="email"
1112
model="user.email"
12-
validators={\{ isEmail, isRequired }}
13+
validators={{ isEmail, isRequired }}
1314
/>
1415

1516
<Errors
1617
model="user.email"
17-
messages={\{
18+
messages={{
1819
isRequired: 'Please provide an email address.',
1920
isEmail: (val) => `${val} is not a valid email.`,
2021
}}
@@ -48,13 +49,13 @@ _(String | Function)_: the string representation of the model path to show the e
4849
```jsx
4950
<Errors
5051
model="user"
51-
messages={\{
52+
messages={{
5253
passwordsMatch: 'Passwords do not match.',
5354
}}
5455
/>
5556
```
5657

57-
## `messages={\{...}}`
58+
## `messages={{...}}`
5859

5960
_(Object)_: a plain object mapping where:
6061
- the keys are error keys (such as `"required"`)
@@ -67,7 +68,7 @@ If the message value is a function, it will be called with the model value.
6768
```jsx
6869
<Errors
6970
model="user.email"
70-
messages={\{
71+
messages={{
7172
required: 'Please enter an email address.',
7273
length: 'The email address is too long.',
7374
invalid: (val) => `${val} is not a valid email address.',
@@ -78,7 +79,7 @@ If the message value is a function, it will be called with the model value.
7879
### Notes
7980
- The `messages` prop is a great place to keep custom error messages that can vary based on the location in the UI, instead of hardcoding error messages in validation fuctions.
8081
- If a message is _not_ provided for an error key, the message will default to the key value in the control's `.errors` property.
81-
- This means if you're using `actions.setErrors` or the `errors={\{...}}` prop in `<Control>` or `<Field>` to set error messages, they will automatically be shown in `<Errors />`.
82+
- This means if you're using `actions.setErrors` or the `errors={{...}}` prop in `<Control>` or `<Field>` to set error messages, they will automatically be shown in `<Errors />`.
8283

8384
## `show={...}`
8485

@@ -90,7 +91,7 @@ It can be a boolean, or a function, string, or object as a [Lodash iteratee](htt
9091
### Examples
9192
- `show={true}` will always show the errors if they exist
9293
- `show={(field) => field.touched && !field.focus}` will show errors if the model's field is touched and not focused
93-
- `show={\{touched: true, focus: false}}` is the same as above
94+
- `show={{touched: true, focus: false}}` is the same as above
9495
- `show="touched"` will show errors if the model's field is touched
9596
9697
### Notes
@@ -119,3 +120,4 @@ _(String | Function | Element)_: The `component`, which is the component for eac
119120
- `fieldValue` - the current field state of the `model`
120121
- `children` - the error message (text).
121122
- `component={CustomError}` will wrap the error in a `<CustomError>` component, which will receive the same props as above.
123+
{% endraw %}

docs/api/Form.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const passwordsMatch = ({ password, confirmPassword }) => {
1414

1515
// in render() return block:
1616
<Form model="user"
17-
validators={\{
17+
validators={{
1818
'': { passwordsMatch },
1919
email: { required, isEmail },
2020
password: { required },
@@ -49,7 +49,7 @@ Typically, the `<Control>` (and/or `<Field>`) components nested inside `<Form>`
4949

5050
You can also use [partial models](../guides/partial-models.md) for `<Control>`, `<Field>`, `<Fieldset>`, and `<Errors>` components inside of `<Form>` - they will be resolved to the form's model.
5151

52-
## `validators={\{...}}`
52+
## `validators={{...}}`
5353
_(Object)_: An object representing the validators for the fields inside the form, where:
5454

5555
- the **keys** are the field model names (e.g. `'email'` for `user.email`)
@@ -65,15 +65,15 @@ Validation will occur on _any field model change_ by default, and only the valid
6565
- Specifying validators on the form is usually sufficient - you don't need to put validators on the `<Field>` or `<Control>` for most use cases.
6666
- If you need validators to run on submit, this is the place to put them.
6767

68-
## `errors={\{...}}`
68+
## `errors={{...}}`
6969
_(Object)_: An object representing the error validators for the fields inside the form, where:
7070

7171
- the **keys** are the field model names (e.g. `'email'` for `user.email`)
7272
- the **values** are error validator(s) for the field model. They can be:
7373
- an error validator function, which receives the field model value, or
7474
- an error validator object, with validation keys and error validator functions as values, also receiving the field model value.
7575

76-
Its behavior is identical to the `validators={\{...}}` prop, with the exception that an error validator that returns anything truthy is interpreted as an _error_. See [the validation guide](../guides/validation.md) for more info.
76+
Its behavior is identical to the `validators={{...}}` prop, with the exception that an error validator that returns anything truthy is interpreted as an _error_. See [the validation guide](../guides/validation.md) for more info.
7777

7878
## `validateOn="..."`
7979
_(String)_: A string that indicates when `validators` or `errors` (for error validators) should run.
@@ -126,7 +126,7 @@ class MyForm extends React.Component {
126126
return (
127127
<Form
128128
model="user"
129-
validators={\{...}}
129+
validators={{...}}
130130
onSubmit={ (user) => this.handleSubmit(user) }
131131
>
132132
<Control type="email" model=".email" />
@@ -170,7 +170,7 @@ class MyForm extends React.Component {
170170
return (
171171
<Form
172172
model="user"
173-
validators={\{...}}
173+
validators={{...}}
174174
onSubmit={...}
175175
onSubmitFailed={ (userForm) => this.handleSubmitFailed(userForm) }
176176
>

docs/guides/compare-redux-form.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ const SyncValidationForm = () => (
165165
<label>Username</label>
166166
<Control.text
167167
placeholder="Username"
168-
validators={\{ required }}
168+
validators={{ required }}
169169
/>
170-
<Errors messages={\{ required: 'Required' }} />
170+
<Errors messages={{ required: 'Required' }} />
171171
</div>
172172
</Form>
173173
);

docs/guides/custom-controls.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ By default, any props on `<Control>` that are _not_ part of the `Control.propTyp
7878
<Control.checkbox
7979
model="user.active"
8080
component={MyCheckbox}
81-
controlProps={\{
81+
controlProps={{
8282
label: 'Is user active?', // will also be passed to MyCheckbox
8383
}}
8484
/>
@@ -120,7 +120,7 @@ const CustomInput = (props) => (
120120
const CustomInputControl = (props) => (
121121
<Control
122122
component={CustomInput}
123-
mapProps={\{
123+
mapProps={{
124124
value: (props) => props.viewValue,
125125
}}
126126
{...props}
@@ -139,13 +139,13 @@ const CustomInputControl = (props) => (
139139

140140
## Advanced Custom Controls
141141

142-
Some custom controls won't have prop keys that match up exactly with the standard event handler props, such as `onChangeText` in React Native's `<TextInput>` component corresponding to `onChange`. You can specify a prop mapping in the `mapProps={\{...}}` prop to specify the mapping:
142+
Some custom controls won't have prop keys that match up exactly with the standard event handler props, such as `onChangeText` in React Native's `<TextInput>` component corresponding to `onChange`. You can specify a prop mapping in the `mapProps={{...}}` prop to specify the mapping:
143143

144144
```jsx
145145
<Control
146146
model="..."
147147
component={DatePickerIOS}
148-
mapProps={\{
148+
mapProps={{
149149
date: (props) => props.modelValue,
150150
onDateChange: (props) => props.onChange,
151151
}}

docs/guides/faqs.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% raw %}
12
# Frequently Asked Questions
23

34
This list will be updated frequently!
@@ -20,12 +21,12 @@ const store = createStore(combineReducers({
2021

2122
### How do you add conditional class names based on field state?
2223

23-
Use the `mapProps={\{...}}` property on `<Control>` components to set any props on the control component based on field state, like this:
24+
Use the `mapProps={{...}}` property on `<Control>` components to set any props on the control component based on field state, like this:
2425

2526
```jsx
2627
<Control.text
2728
model="user.firstName"
28-
mapProps={\{
29+
mapProps={{
2930
className: ({fieldValue}) => fieldValue.focus
3031
? 'focused'
3132
: ''
@@ -42,7 +43,7 @@ The props that are provided to each function value in your `mapProps` mapping ar
4243

4344
as well as other additional props:
4445
- all props on the `<Control>`
45-
- all props on the `controlProps={\{...}}` prop (if any)
46+
- all props on the `controlProps={{...}}` prop (if any)
4647
- `onKeyPress`
4748
- `viewValue`
4849

@@ -59,7 +60,7 @@ const BirthDate = ({forModel}) => (
5960
<Form
6061
model={`${forModel}.birth`}
6162
component="div"
62-
validators={\{
63+
validators={{
6364
'': ({day, month, year}) => isOver18(day, month, year),
6465
}}
6566
>
@@ -156,3 +157,4 @@ class UploadForm extends Component {
156157

157158
### Other Questions and Answers
158159
- https://github.com/davidkpiano/react-redux-form/issues/675#issuecomment-281164930
160+
{% endraw %}

0 commit comments

Comments
 (0)