Skip to content

Validating a string is a valid Uri

import 'package:luthor/luthor.dart';
void main() {
final validator = l.string().uri();
print(validator.validateValue('https://example.com'));
}
import 'package:luthor/luthor.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'uri.freezed.dart';
part 'uri.g.dart';
@freezed
@luthor
class UriSchema extends _$UriSchema {
const factory UriSchema({
required String value,
}) = _$UriSchema;
static SchemaValidationResult<UriSchema> validate(
Map<String, dynamic> json,
) =>
_$UriSchemaValidate(json);
factory UriSchema.fromJson(Map<String, dynamic> json) =>
_$UriSchemaFromJson(json);
}
void main() {
print(UriSchema.validate({'value': 'https://example.com'}));
}