redux-form-normalize
v0.1.2
Published
Strings normalizer for redux-form
Downloads
342
Maintainers
Readme
redux-form-normalize
Description
A small library for strings normalizing in redux-form
Installation
npm i redux-form-normalize
or
yarn add redux-form-normalize
Usage
import React, { Component } from 'react'
import { Field, reduxForm } from 'redux-form'
import { normalize } from 'redux-form-normalize'
class ExampleForm extends Component {
submit = (values, dispatch) => {
dispatch({
type: 'EXAMPLE_REQUEST',
payload: {}
})
}
render() {
const { handleSubmit } = this.props
return (
<form onSubmit={handleSubmit(this.submit)}>
<div className="g-auth__tab">
<div className="g-field__wrapper">
<Field
name="price"
component="input"
type="text"
placeholder="Price"
normalize={normalize.float(2)}
/>
</div>
</div>
<div>
<button type="submit">
SUBMIT
</button>
<button type="button">
BACK
</button>
</div>
</form>
)
}
}
export default reduxForm({
form: 'exampleForm'
})(ExampleForm)
Methods
| Method | Description |
| :--- | :--- |
| integer(x)
| x - amount of numbers |
| float(x)
| x - amount of decimal places |
| currency(x)
| x - currency symbol (for example - 'USD') |
| phone
| - U.S. phone number |