UNPKG

react-native-confirmation-code-field

Version:

A react-native component to input confirmation code for both Android and IOS

23 lines (19 loc) 579 B
// @flow import type { PropsTypeCustomValidatorFn } from './types'; export const validateCompareCode: PropsTypeCustomValidatorFn = ( props, propName, componentName, ) => { const compareWithCode = props[propName]; if (compareWithCode) { const { codeLength } = props; if (compareWithCode.length !== codeLength) { return new Error( `Invalid prop ${propName} supplied to ${componentName}. Validation failed. ${propName} length is not equal to "codeLength" (${ compareWithCode.length } !== ${codeLength}).`, ); } } };