isUrl function
- bool strict = false,
Validates that the String is a valid URL. By it uses non-strict validation (like "example.com").
If you want to enforce strict validation (must include scheme), set strict
to true or use isStrictUrl.
Implementation
IValidator isUrl({bool strict = false}) {
return isString() &
validator(
(value) =>
strict ? Uri.tryParse(value)?.isAbsolute ?? false : Uri.tryParse(value) != null,
(value) => Expectation(message: 'a valid URL', value: value, code: 'value.format_invalid', data: {'format': 'url'}),
);
}