doValidate method

  1. @override
ValidationResult doValidate()
override

Implementation

@override
ValidationResult doValidate() {
  // Ownership rules:
  // ------------------
  // Rule 1: For a cached key owner should be different from the current @sign.
  // Rule 2: For a non cached key owner should be same as the current @sign.
  // A non cached key can be Public, Private, Hidden or just a self key
  if ((type == KeyType.cachedPublicKey || type == KeyType.cachedSharedKey) &&
      (owner == atSign)) {
    return ValidationResult(
        'Owner of the key $owner should not be same as the the current @sign $atSign for a cached key');
  }
  if ((type != KeyType.cachedPublicKey && type != KeyType.cachedSharedKey) &&
      owner != atSign) {
    return ValidationResult(
        'Owner of the key $owner should be same as current @sign $atSign');
  }
  return ValidationResult.noFailure();
}