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

Commit 57dec2f

Browse files
committed
Fixing docs and accidental committed code
1 parent 8c7ec89 commit 57dec2f

File tree

8 files changed

+53
-57
lines changed

8 files changed

+53
-57
lines changed

docs/api/Control.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ export default createStore(combineForms({
8888
It can also be a function that returns a string model. See [the documentation on tracking](../guides/tracking.md) for more information.
8989

9090
<h2 id="prop-mapProps"></h2>
91-
## `mapProps={{...}}`
91+
## `mapProps={\{...}}`
9292
_(Object)_: A mapping of control-specific property keys to prop-getter functions that taken in the original props and return the result prop. See [the documentation on custom controls](../guides/custom-controls.md) for more information.
9393

9494
Example:
9595
```jsx
9696
<Control
97-
mapProps={{
97+
mapProps={\{
9898
customChange: (props) => props.change,
9999
}}
100100
model="..."
@@ -118,15 +118,15 @@ You can also specify `updateOn={['change', 'blur']}` as an array of one or more
118118
- Use the `changeAction` prop if you want to dispatch custom actions along with the `actions.change(...)` action.
119119

120120
<h2 id="prop-validators"></h2>
121-
## `validators={{...}}`
121+
## `validators={\{...}}`
122122
_(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.
123123

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

126126
```jsx
127127
<Control.text
128128
model="user.username"
129-
validators={{
129+
validators={\{
130130
required: (val) => val.length,
131131
length: (val) => val.length > 4
132132
}}
@@ -142,7 +142,7 @@ const length = (val) => val.length > 8;
142142

143143
<Control.text
144144
model="user.username"
145-
validators={{ required, length }}
145+
validators={\{ required, length }}
146146
/>
147147
```
148148

@@ -158,7 +158,7 @@ _(String | Array)_: A string/array of strings specifying when validation should
158158
- 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.
159159

160160
<h2 id="prop-asyncValidators"></h2>
161-
## `asyncValidators={{...}}`
161+
## `asyncValidators={\{...}}`
162162
_(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.
163163

164164
Each async validator function is called with 2 arguments:
@@ -172,7 +172,7 @@ For example, this control validates that a username is available via a promise:
172172
import isAvailable from '../path/to/is-available';
173173

174174
<Control.text model="user.username"
175-
asyncValidators={{
175+
asyncValidators={\{
176176
isAvailable: (value, done) => {
177177
isAvailable(value)
178178
.then((result) => done(result));
@@ -191,7 +191,7 @@ _(String | Array)_: A string/array of strings specifying when async validation s
191191
- `"focus"` - validate on the `onFocus` event handler
192192

193193
<h2 id="prop-errors"></h2>
194-
## `errors={{...}}`
194+
## `errors={\{...}}`
195195
_(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.
196196

197197
An **error validator** is a function that returns `true` or a truthy value (such as a string) if invalid, and `false` if valid.
@@ -201,7 +201,7 @@ For example, this control validates that a username exists and is longer than 4
201201
```jsx
202202
<Control.text
203203
model="user.username"
204-
errors={{
204+
errors={\{
205205
isEmpty: (val) => !val.length,
206206
tooLong: (val) => val.length > 16,
207207
}}
@@ -270,7 +270,7 @@ function changeAndSubmit(model, value) {
270270
- Since `changeAction` expects an action creator and `redux-thunk` is used, you can asynchronously dispatch actions (like the example above).
271271

272272
<h2 id="prop-controlProps"></h2>
273-
## `controlProps={{...}}`
273+
## `controlProps={\{...}}`
274274
_(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} />`).
275275

276276
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.
@@ -282,7 +282,7 @@ Example:
282282
<Control.text
283283
model="..."
284284
component={CustomInput}
285-
controlProps={{errors: 'errors for CustomInput'}}
285+
controlProps={\{errors: 'errors for CustomInput'}}
286286
/>
287287
```
288288

@@ -325,7 +325,7 @@ However, in `<Control>`, it can be a boolean, or a function, string, or object a
325325
// Disable the submit button when the form is invalid
326326
<Control.button
327327
model="user"
328-
disabled={{ valid: false }}
328+
disabled={\{ valid: false }}
329329
>
330330
Submit!
331331
</Control.button>
@@ -334,7 +334,7 @@ However, in `<Control>`, it can be a boolean, or a function, string, or object a
334334
For example:
335335
- `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
336336
- `disabled="touched"` will disable if the field is `touched` (works with any property on the field)
337-
- `disabled={{ valid: false, touched: true }}` will disable if the field is both `touched` and not `valid`
337+
- `disabled={\{ valid: false, touched: true }}` will disable if the field is both `touched` and not `valid`
338338
- `disabled={(fieldValue) => !fieldValue.valid}` will call the function provided with the `fieldValue` to determine its `disabled` state.
339339

340340
(since: version 1.3.0)
@@ -360,7 +360,7 @@ _(Boolean)_: Signifies that the field state (validation, etc.) should not persis
360360
// even when the control is unmounted.
361361
<Control.text
362362
model="user.name"
363-
validators={{ length: (value) => value.length > 8 }}
363+
validators={\{ length: (value) => value.length > 8 }}
364364
persist
365365
/>
366366
```

docs/api/Errors.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ The `<Errors />` component provides a handy way of displaying form errors for a
99
<Control.text
1010
type="email"
1111
model="user.email"
12-
validators={{ isEmail, isRequired }}
12+
validators={\{ isEmail, isRequired }}
1313
/>
1414

1515
<Errors
1616
model="user.email"
17-
messages={{
17+
messages={\{
1818
isRequired: 'Please provide an email address.',
1919
isEmail: (val) => `${val} is not a valid email.`,
2020
}}
@@ -48,13 +48,13 @@ _(String | Function)_: the string representation of the model path to show the e
4848
```jsx
4949
<Errors
5050
model="user"
51-
messages={{
51+
messages={\{
5252
passwordsMatch: 'Passwords do not match.',
5353
}}
5454
/>
5555
```
5656

57-
## `messages={{...}}`
57+
## `messages={\{...}}`
5858

5959
_(Object)_: a plain object mapping where:
6060
- the keys are error keys (such as `"required"`)
@@ -67,7 +67,7 @@ If the message value is a function, it will be called with the model value.
6767
```jsx
6868
<Errors
6969
model="user.email"
70-
messages={{
70+
messages={\{
7171
required: 'Please enter an email address.',
7272
length: 'The email address is too long.',
7373
invalid: (val) => `${val} is not a valid email address.',
@@ -78,19 +78,19 @@ If the message value is a function, it will be called with the model value.
7878
### Notes
7979
- 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.
8080
- 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 />`.
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 />`.
8282

8383
## `show={...}`
8484

8585
_(Any)_: The `show` prop determines when error messages should be shown, based on the model's field state (determined by the form reducer).
8686
87-
It can be a boolean, or a function, string, or object as a [Lodash iteratee](https://lodash.com/docs#iteratee).
87+
It can be a boolean, or a function, string, or object as a [Lodash iteratee](https://lodash.com/docs#iteratee).
8888
8989
9090
### Examples
9191
- `show={true}` will always show the errors if they exist
9292
- `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
93+
- `show={\{touched: true, focus: false}}` is the same as above
9494
- `show="touched"` will show errors if the model's field is touched
9595
9696
### Notes
@@ -112,7 +112,7 @@ _(String | Function | Element)_: The `wrapper` component, which is the component
112112
113113
_(String | Function | Element)_: The `component`, which is the component for each error message, can be configured using this prop. Default: `"span"`.
114114
115-
### Examples
115+
### Examples
116116
- `component="li"` will wrap all errors in a `<li>`
117117
- `component={(props) => <div className="error">{props.children}</div>}` will render the error message in the specified functional component, with these props:
118118
- `modelValue` - the current value of the `model`

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.
@@ -124,7 +124,7 @@ class MyForm extends React.Component {
124124
return (
125125
<Form
126126
model="user"
127-
validators={{...}}
127+
validators={\{...}}
128128
onSubmit={ (user) => this.handleSubmit(user) }
129129
>
130130
<Control type="email" model=".email" />
@@ -168,7 +168,7 @@ class MyForm extends React.Component {
168168
return (
169169
<Form
170170
model="user"
171-
validators={{...}}
171+
validators={\{...}}
172172
onSubmit={...}
173173
onSubmitFailed={ (userForm) => this.handleSubmitFailed(userForm) }
174174
>

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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import CustomInput from '../path/to/custom-input-component';
1414
class MyCustomInput extends React.Component {
1515
render() {
1616
const { model, dispatch } = this.props;
17-
17+
1818
return (
1919
<CustomInput
2020
onCustomChange={e => dispatch(actions.change(model, e))}
@@ -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
/>
@@ -105,7 +105,7 @@ const CustomInput = (props) => (
105105
const CustomInputControl = (props) => (
106106
<Control
107107
component={CustomInput}
108-
mapProps={{
108+
mapProps={\{
109109
value: (props) => props.viewValue,
110110
}}
111111
{...props}
@@ -124,13 +124,13 @@ const CustomInputControl = (props) => (
124124

125125
## Advanced Custom Controls
126126

127-
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:
127+
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:
128128

129129
```jsx
130130
<Control
131131
model="..."
132132
component={DatePickerIOS}
133-
mapProps={{
133+
mapProps={\{
134134
date: (props) => props.modelValue,
135135
onDateChange: (props) => props.onChange,
136136
}}

docs/guides/faqs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ const store = createStore(combineReducers({
2020

2121
### How do you add conditional class names based on field state?
2222

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

2525
```jsx
2626
<Control.text
2727
model="user.firstName"
28-
mapProps={{
28+
mapProps={\{
2929
className: ({fieldValue}) => fieldValue.focus
3030
? 'focused'
3131
: ''
@@ -42,7 +42,7 @@ The props that are provided to each function value in your `mapProps` mapping ar
4242

4343
as well as other additional props:
4444
- all props on the `<Control>`
45-
- all props on the `controlProps={{...}}` prop (if any)
45+
- all props on the `controlProps={\{...}}` prop (if any)
4646
- `onKeyPress`
4747
- `viewValue`
4848

@@ -59,7 +59,7 @@ const BirthDate = ({forModel}) => (
5959
<Form
6060
model={`${forModel}.birth`}
6161
component="div"
62-
validators={{
62+
validators={\{
6363
'': ({day, month, year}) => isOver18(day, month, year),
6464
}}
6565
>

0 commit comments

Comments
 (0)