Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-form-numeric-field

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-form-numeric-field

a customized redux-form Field for entering numbers

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
325
increased by24.05%
Maintainers
1
Weekly downloads
 
Created
Source

redux-form-numeric-field

Build Status Coverage Status semantic-release Commitizen friendly npm version

A customized redux-form Field for entering numbers. It isn't contrary; it won't stop you from typing, pasting, or cutting any characters, though it will produce a "must be a number" validation error immediately if the current input is invalid. When it loses focus it will normalize its value to a number, if valid; otherwise it will trim its value but leave it as a string.

Usage

npm install --save redux-form-numeric-field
const { NumericField } = require('redux-form-numeric-field')

or

const { NumericField } = require('redux-form-numeric-field/immutable')

Example

The following field will normalize its value to a number when it loses focus (unless the text is not a valid number, in which case it will just trim the text when it loses focus).

<NumericField name="value" component={YourInputComponent} />

API

NumericField

Has the same API as redux-form's Field, but normalizes its value to a number when it loses focus (unless the text is not a valid number, in which case it will just trim the text when it loses focus).

normalizeNumber?: (value: ?(string | number)) => ?(string | number)

Allows you to override the default implementation which is called on blur. If value is a number or correctly-formatted string, return a number; otherwise, return a string or null.

normalizeOnBlur?: (value: ?(string | number)) => ?(string | number)

If you provide this, it will be called with the output of normalizeNumber when the field loses focus.

validate?: Validator | Array<Validator>

Unlike a normal Field, NumericField will call your validators with the normalized value from normalizeNumber. If its value is an invalid number but not whitespace, it will produce a "must be a number" validation error without calling your own validators.

Keywords

FAQs

Package last updated on 05 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc