validate method

Exception? validate()

Implementation

Exception? validate() {
  final regEx = RegExp(r'^[a-z][a-z0-9]{2,15}$');

  if (!regEx.hasMatch(denom)) {
    return Exception('invalid denom: $denom');
  }

  if (!isPositive) {
    return Exception('negative coin amount: $amount');
  }

  return null;
}