ValidationUtils class

Utility class for input validation and sanitization.

This class provides static methods for validating and sanitizing user input related to payment processing. It includes validation for emails, phone numbers, card details, amounts, and other payment-related data.

Features

  • Email format validation
  • Phone number validation (E.164 format)
  • Card number validation with Luhn algorithm
  • CVV and expiry date validation
  • Amount validation with currency-specific limits
  • Input sanitization

Example

// Validate card details
bool validCard = ValidationUtils.isValidCardNumber('4084084084084081');
bool validExpiry = ValidationUtils.isValidExpiryDate('12', '25');
bool validCvv = ValidationUtils.isValidCvv('408');

// Validate amount
bool validAmount = ValidationUtils.isValidAmount(50000, Currency.ngn);

Constructors

ValidationUtils.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

isValidAmount(int amount, Currency currency) bool
Validate amount (must be positive, reasonable limit).
isValidCardNumber(String cardNumber) bool
Validate card number format and Luhn algorithm.
isValidCvv(String cvv) bool
Validate CVV format.
isValidEmail(String email) bool
Validate email format.
isValidExpiryDate(String month, String year) bool
Validate expiry date format and not expired.
isValidPhoneNumber(String phone) bool
Validate phone number format (E.164).
sanitizeString(String input) String
Sanitize string input by trimming and removing control characters.