UNPKG

react-native-moyasar-sdk

Version:

Official React Native Moyasar SDK - Integrate Credit Cards, Apple Pay, Samsung Pay, and STC Pay with simple interfaces for a seamless payment experience in your React Native app

28 lines (27 loc) 612 B
"use strict"; export class FieldValidator { rules = []; shouldErr = false; addRule(error, predicate) { this.rules.push({ predicate, error }); } visualValidate(value, creditCardNumber) { this.shouldErr = this.shouldErr || value !== ''; if (!this.shouldErr) { return null; } return this.validate(value, creditCardNumber); } validate(value, creditCardNumber) { for (const rule of this.rules) { if (rule.predicate(value, creditCardNumber)) { return rule.error; } } return null; } } //# sourceMappingURL=field_validator.js.map