Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharedPartBuilder partId validation regex and error message are inconsistent #607

Open
Clavum opened this issue Jun 24, 2022 · 1 comment

Comments

@Clavum
Copy link

Clavum commented Jun 24, 2022

https://github.com/dart-lang/source_gen/blob/master/source_gen/lib/src/builder.dart

If partId provided to the SharedPartBuilder doesn't meet regex validation, an error is thrown:

if (!_partIdRegExp.hasMatch(partId)) {
  throw ArgumentError.value(
    partId,
    'partId',
    '`partId` can only contain letters, numbers, `_` and `.`. '
        'It cannot start or end with `.`.',
  );
}

It states partId can contain a period, however, here's the regex:

const partIdRegExpLiteral = r'[A-Za-z_\d-]+';

final _partIdRegExp = RegExp('^$partIdRegExpLiteral\$');

As you can see, no period is allowed.

Either the error message or regex should be updated to be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Clavum and others