2018-12-10 17:51:10 +00:00
|
|
|
import 'package:angel_validate/angel_validate.dart';
|
|
|
|
|
|
|
|
main() {
|
2019-08-11 18:48:11 +00:00
|
|
|
var bio = new Validator({
|
|
|
|
'age*': [isInt, greaterThanOrEqualTo(0)],
|
|
|
|
'birthYear*': isInt,
|
|
|
|
'countryOfOrigin': isString
|
|
|
|
});
|
2018-12-10 17:51:10 +00:00
|
|
|
|
2019-08-11 18:48:11 +00:00
|
|
|
var book = new Validator({
|
|
|
|
'title*': isString,
|
|
|
|
'year*': [
|
|
|
|
isNum,
|
|
|
|
(year) {
|
|
|
|
return year <= new DateTime.now().year;
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
2018-12-10 17:51:10 +00:00
|
|
|
|
2019-08-11 18:48:11 +00:00
|
|
|
// ignore: unused_local_variable
|
|
|
|
var author = new Validator({
|
|
|
|
'bio*': bio,
|
|
|
|
'books*': [isList, everyElement(book)]
|
|
|
|
}, defaultValues: {
|
|
|
|
'books': []
|
|
|
|
});
|
|
|
|
}
|