FhirPositiveInt constructor

FhirPositiveInt(
  1. dynamic inValue
)

Implementation

factory FhirPositiveInt(dynamic inValue) {
  if (inValue is int) {
    return inValue > 0
        ? FhirPositiveInt._(inValue.toString(), inValue, true)
        : FhirPositiveInt._(inValue.toString(), null, false);
  } else if (inValue is num) {
    final int? tempPositiveInt = int.tryParse(inValue.toString());
    return tempPositiveInt == null
        ? FhirPositiveInt._(inValue.toString(), null, false)
        : tempPositiveInt > 0
            ? FhirPositiveInt._(inValue.toString(), tempPositiveInt, true)
            : FhirPositiveInt._(inValue.toString(), null, false);
  }
  throw CannotBeConstructed<FhirPositiveInt>(
      'PositiveInt cannot be constructed from $inValue.');
}