UuidValue constructor Null safety

UuidValue(
  1. String uuid,
  2. [bool validate = true]
)

UuidValue() Constructor for creating a uuid value.

Takes in a string representation of a uuid to wrap.

Optionally , you can disable the validation check in the constructor by setting validate to false.

Implementation

factory UuidValue(String uuid, [bool validate = true]) {
  if (validate && !Uuid.isValidUUID(fromString: uuid)) {
    throw FormatException('The provided UUID is invalid.', uuid);
  }

  return UuidValue._(uuid.toLowerCase());
}