Skip to content

Commit

Permalink
More ways to pass NoDashes
Browse files Browse the repository at this point in the history
  • Loading branch information
daegalus committed Dec 12, 2023
1 parent 54e0f11 commit 73de7f3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

v4.3.1

* Add additional optional parameters for parseing and validation for the new noDashes flag.

v4.3.0

* Update SDK constraints to >= 3.0.0
Expand Down
21 changes: 11 additions & 10 deletions lib/parsing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ class UuidParsing {
/// Throws [RangeError] if a [buffer] is provided and it is too small.
/// It is also thrown if a non-zero [offset] is provided without providing
/// a [buffer].
static List<int> parse(
String uuid, {
List<int>? buffer,
int offset = 0,
bool validate = true,
ValidationMode validationMode = ValidationMode.strictRFC4122,
}) {
static List<int> parse(String uuid,
{List<int>? buffer,
int offset = 0,
bool validate = true,
ValidationMode validationMode = ValidationMode.strictRFC4122,
bool noDashes = false}) {
if (validate) {
UuidValidation.isValidOrThrow(
fromString: uuid, validationMode: validationMode);
fromString: uuid, validationMode: validationMode, noDashes: noDashes);
}
var i = offset, ii = 0;

Expand Down Expand Up @@ -96,12 +95,14 @@ class UuidParsing {
{List<int>? buffer,
int offset = 0,
bool validate = true,
ValidationMode validationMode = ValidationMode.strictRFC4122}) {
ValidationMode validationMode = ValidationMode.strictRFC4122,
bool noDashes = false}) {
return Uint8List.fromList(parse(uuid,
buffer: buffer,
offset: offset,
validate: validate,
validationMode: validationMode));
validationMode: validationMode,
noDashes: noDashes));
}

/// Unparses a [buffer] of bytes and outputs a proper UUID string.
Expand Down
10 changes: 6 additions & 4 deletions lib/uuid_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class UuidValue {
/// the uuid string.
/// Throws [FormatException] if the UUID is invalid.
factory UuidValue.withValidation(String uuid,
[ValidationMode validationMode = ValidationMode.strictRFC4122]) {
[ValidationMode validationMode = ValidationMode.strictRFC4122,
bool noDashes = false]) {
final uuidValue = UuidValue.fromString(uuid);
uuidValue.validate(validationMode);
uuidValue.validate(validationMode, noDashes);
return uuidValue;
}

Expand Down Expand Up @@ -61,9 +62,10 @@ class UuidValue {
/// the uuid string.
/// Throws [FormatException] if the UUID is invalid.
void validate(
[ValidationMode validationMode = ValidationMode.strictRFC4122]) {
[ValidationMode validationMode = ValidationMode.strictRFC4122,
bool noDashes = false]) {
UuidValidation.isValidOrThrow(
fromString: uuid, validationMode: validationMode);
fromString: uuid, validationMode: validationMode, noDashes: noDashes);
}

// toBytes() converts the internal string representation to a list of bytes.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: uuid
version: 4.3.0
version: 4.3.1
description: >
RFC4122 (v1, v4, v5, v6, v7, v8) UUID Generator and Parser for Dart
documentation: https://daegalus.github.io/dart-uuid/index.html
Expand Down

0 comments on commit 73de7f3

Please sign in to comment.