validate method

  1. @override
void validate()
override

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

Implementation

@override
void validate() {
  assert(customerKey.length <= 36);

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

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

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