platform/packages/validate/example/main.dart

28 lines
522 B
Dart
Raw Permalink Normal View History

2019-10-17 00:13:36 +00:00
import 'package:angel_validate/angel_validate.dart';
2021-02-14 05:22:25 +00:00
main() {
var bio = Validator({
'age*': [isInt, greaterThanOrEqualTo(0)],
'birthYear*': isInt,
'countryOfOrigin': isString
2019-10-17 00:54:38 +00:00
});
2021-02-14 05:22:25 +00:00
var book = Validator({
'title*': isString,
'year*': [
isNum,
(year) {
return year <= DateTime.now().year;
}
]
2019-10-17 00:54:38 +00:00
});
2021-02-14 05:22:25 +00:00
// ignore: unused_local_variable
var author = Validator({
'bio*': bio,
'books*': [isList, everyElement(book)]
}, defaultValues: {
'books': []
2019-10-17 00:13:36 +00:00
});
}