validate method

void validate()

Validate the request data.

Performs comprehensive validation on the payment request including:

  • Amount validation (positive, within currency limits)
  • Email format validation
  • Reference format validation (if provided)
  • Callback URL validation (if provided)

Throws

Implementation

void validate() {
  // Validate amount
  if (!ValidationUtils.isValidAmount(amount, currency)) {
    throw ArgumentError(
      'Amount must be greater than 0 and not exceed the maximum limit for ${currency.name.toUpperCase()}',
    );
  }

  // Validate email
  if (email.isEmpty) {
    throw ArgumentError('Email address is required');
  }
  if (!ValidationUtils.isValidEmail(email)) {
    throw ArgumentError('Invalid email address format');
  }

  // Validate reference if provided
  if (reference != null && reference!.isEmpty) {
    throw ArgumentError('Reference cannot be empty if provided');
  }

  // Validate callback URL if provided
  if (callbackUrl != null && callbackUrl!.isNotEmpty) {
    try {
      Uri.parse(callbackUrl!);
    } catch (e) {
      throw ArgumentError('Invalid callback URL format');
    }
  }
}