validate property

  1. @override
String? get validate
override

Implementation

@override
String? get validate {
  if (signerQuorum == 0 && signerEntries != null) {
    return "Must not include a signerEntries value if the signer list is being deleted.";
  }
  if (signerQuorum != 0 && signerEntries == null) {
    return "Must have a value of zero for signerQuorum if the signer list is being deleted.";
  }

  if (signerEntries == null) {
    return null;
  }

  if (signerQuorum <= 0) {
    return "signerQuorum must be greater than or equal to 0 when not deleting signer list.";
  }

  if (signerEntries != null &&
      (signerEntries!.isEmpty ||
          signerEntries!.length > _maxSignerEnteries)) {
    return "signerEntries must have at least 1 member and no more than $_maxSignerEnteries members. If this transaction is deleting the SignerList, then this parameter must be omitted.";
  }

  Set<String> accountSet = {};
  int signerWeightSum = 0;
  final RegExp hexWalletLocatorRegex = RegExp(r'^[A-Fa-f0-9]{64}$');
  for (SignerEntry signerEntry in signerEntries ?? []) {
    if (signerEntry.account == account) {
      return "The account submitting the transaction cannot appear in a signer entry.";
    }
    if (signerEntry.walletLocator != null &&
        !hexWalletLocatorRegex.hasMatch(signerEntry.walletLocator!)) {
      return "A SignerEntry's walletLocator must be a 256-bit (32-byte) hexadecimal value.";
    }
    accountSet.add(signerEntry.account);
    signerWeightSum += signerEntry.signerWeight;
  }

  if (signerQuorum > signerWeightSum) {
    return "signerQuorum must be less than or equal to the sum of the SignerWeight values in the signerEntries list.";
  }

  if (accountSet.length != signerEntries!.length) {
    return "An account cannot appear multiple times in the list of signer entries.";
  }
  return null;
}