validate method

  1. @override
void validate()
override

Метод проверяет валидность данных

Implementation

@override
void validate() {
  assert(paymentId.length <= 20);

  if (cardData != null || encryptedPaymentData != null) {
    assert((cardData != null) ^ (encryptedPaymentData != null));
  }

  if (encryptedPaymentData != null) {
    assert(route != null);
    assert(source != null);
  }

  final int? _amount = amount;
  if (_amount != null) {
    assert(_amount.length <= 10);
  }

  final String? _phone = phone;
  if (_phone != null) {
    final bool match = RegExp(r'^\+[0-9](?:[\d]*)$').hasMatch(_phone);
    assert(_phone.length <= 19 && match);
  }

  final bool? _sendEmail = sendEmail;
  final String? _infoEmail = infoEmail;
  if (_sendEmail == true) {
    final bool match =
        RegExp(r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$')
            .hasMatch(infoEmail ?? '');
    assert(_infoEmail != null && _infoEmail.length <= 100 && match);
  }

  final String? _ip = ip;
  if (_ip != null) {
    assert(_ip.length >= 7 && _ip.length <= 45);
  }

  final Route? _route = route;
  final Source? _source = source;
  if (_route != null) {
    assert(_source != null && _source != Source.cards);
  }
}