platform/packages/validate/example/main.dart
2024-10-12 18:45:27 -07:00

27 lines
533 B
Dart

import 'package:protevus_validate/protevus_validate.dart';
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': []
});
}