Skip to content

Commit bac30b1

Browse files
authored
[pub_formats] pubspec.yaml allow version: any (#2460)
1 parent 6fe6fa3 commit bac30b1

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

pkgs/pub_formats/doc/schema/pubspec.schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@
123123
},
124124
"version": {
125125
"description": "The version constraint for the package on the custom hosted server.",
126-
"type": "string",
127-
"pattern": "^[<>=~^0-9. -]+$"
126+
"type": "string"
128127
}
129128
},
130129
"required": [

pkgs/pub_formats/lib/src/pubspec_syntax.g.dart

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,13 @@ class HostedDependencySourceSyntax extends DependencySourceSyntax {
223223

224224
List<String> _validateHosted() => _reader.validate<String?>('hosted');
225225

226-
static final _versionPattern = RegExp(r'^[<>=~^0-9. -]+$');
227-
228-
String get version => _reader.string('version', _versionPattern);
226+
String get version => _reader.get<String>('version');
229227

230228
set _version(String value) {
231-
if (!_versionPattern.hasMatch(value)) {
232-
throw ArgumentError.value(
233-
value,
234-
'value',
235-
'Value does not satisify pattern: ${_versionPattern.pattern}.',
236-
);
237-
}
238229
json.setOrRemove('version', value);
239230
}
240231

241-
List<String> _validateVersion() =>
242-
_reader.validateString('version', _versionPattern);
232+
List<String> _validateVersion() => _reader.validate<String>('version');
243233

244234
@override
245235
List<String> validate() => [

pkgs/pub_formats/test_data/pubspec_1.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ dependencies:
2626
version: ^1.4.0
2727
some_hosted_dependency_2:
2828
version: ^1.4.0
29+
some_hosted_dependency_3:
30+
version: any
2931
some_path_dependency:
3032
path: ../some_path_dependency/
3133

0 commit comments

Comments
 (0)