isValidatedQuantity static method

bool isValidatedQuantity(
  1. Object other
)

Implementation

static bool isValidatedQuantity(Object other) {
  if (other is ValidatedQuantity) {
    return other.isValid();
  } else if (other is UcumDecimal) {
    return ValidatedQuantity(value: other).isValid();
  } else if (other is num || other is BigInt) {
    return ValidatedQuantity.fromString(other.toString()).isValid();
  } else if (other is String) {
    return ValidatedQuantity.fromString(other).isValid();
  } else if (other is Map<String, dynamic>) {
    return ValidatedQuantity(
            value: UcumDecimal.fromString(other['value']?.toString()),
            unit: other['code']?.toString() ?? other['value']?.toString())
        .isValid();
  } else {
    return false;
  }
}