1.0.3 • Published 2 years ago

@big-toni/react-native-credit-card-input v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@big-toni/react-native-credit-card-input

Features

DEPENDENCIES

  • "card-validator": "8.1.1",
  • "prop-types": "^15.8.1"

Setup

This library is available on npm, install it with: npm i @big-toni/react-native-credit-card-input or yarn add @big-toni/react-native-credit-card-input.

Demo

Alt Text

Usage

import { CreditCardInput } from '@big-toni/react-native-credit-card-input';
...
<CreditCardInput
  onChange={handleOnChange}
  onError={handleOnError}
  inputStyle={styles.cardField}
  requiresZip
  autoFocus
/>

Available props

PropTypeDefaultDescription
autoFocusPropTypes.boolfalseAutomatically focus 'number' field on render
inputStyleText.propTypes.stylenullStyle for credit card's TextInput
invalidColorPropTypes.stringredColor that will be applied for text input while in 'invalid' state
onChangePropTypes.func() => nullReceives a formData object every time the values change
onErrorPropTypes.func() => nullReceives an errors object every time the values change
onFocusPropTypes.func() => nullReceives the name of currently focused field
placeholderColorPropTypes.stringgrayColor that will be applied for text input placeholder
placeholdersPropTypes.string{ number: '1234 5678 1234 5678', expiry: 'MM/YY', cvv: 'CVV', zip: 'ZIP'}Placeholders object
requiresZipPropTypes.boolfalseShows zip input field
validateZipPropTypes.func(zip = '') => { return zip.match(/^\d{6}$/) ? 'valid' : zip.length > 6 ? 'invalid' : 'incomplete'; }Function to validate ZIP, expects 'incomplete', 'valid', or 'invalid' as return value