platform/packages/validation/example/main.dart

28 lines
537 B
Dart
Raw Permalink Normal View History

import 'package:platform_validation/platform_validation.dart';
2024-12-15 19:34:52 +00:00
void main() {
var bio = Validator({
'age*': [isInt, greaterThanOrEqualTo(0)],
'birthYear*': isInt,
'countryOfOrigin': isString
});
var book = Validator({
'title*': isString,
'year*': [
isNum,
(year) {
return year <= DateTime.now().year;
}
]
});
// ignore: unused_local_variable
var author = Validator({
'bio*': bio,
'books*': [isList, everyElement(book)]
}, defaultValues: {
'books': []
});
}