validate method

String? validate(
  1. String unit
)

Implementation

String? validate(String unit) {
  assert(unit.isNotEmpty,
      paramError('validate', 'unit', 'must not be null or empty'));
  try {
    ExpressionParser(model).parse(unit);
    return null;
  } catch (e) {
    if (e is UcumException) {
      return e.message;
    } else {
      return e.toString();
    }
  }
}