Skip to content

Validating a string is a valid CUID 2

import 'package:luthor/luthor.dart';
void main() {
final validator = l.string().cuid();
print(validator.validateValue('gnu9eq6nqho8zk0cq4uev49x'));
}
import 'package:luthor/luthor.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'cuid_2.freezed.dart';
part 'cuid_2.g.dart';
@freezed
@luthor
class Cuid2Schema extends _$Cuid2Schema {
const factory Cuid2Schema({
required String value,
}) = _$Cuid2Schema;
static SchemaValidationResult<Cuid2Schema> validate(
Map<String, dynamic> json,
) =>
_$Cuid2SchemaValidate(json);
factory Cuid2Schema.fromJson(Map<String, dynamic> json) =>
_$Cuid2SchemaFromJson(json);
}
void main() {
print(Cuid2Schema.validate({'value': 'gnu9eq6nqho8zk0cq4uev49x'}));
}