29 lines
612 B
Dart
29 lines
612 B
Dart
|
import 'package:angel_validate/angel_validate.dart';
|
||
|
|
||
|
main() {
|
||
|
var bio = new Validator({
|
||
|
'age*': [isInt, greaterThanOrEqualTo(0)],
|
||
|
'birthYear*': isInt,
|
||
|
'countryOfOrigin': isString
|
||
|
});
|
||
|
|
||
|
var book = new Validator({
|
||
|
'title*': isString,
|
||
|
'year*': [
|
||
|
isNum,
|
||
|
(year) {
|
||
|
return year <= new DateTime.now().year;
|
||
|
}
|
||
|
]
|
||
|
});
|
||
|
|
||
|
var author = new Validator({
|
||
|
'bio*': bio,
|
||
|
'books*': [
|
||
|
isList,
|
||
|
everyElement(book)
|
||
|
]
|
||
|
}, defaultValues: {
|
||
|
'books': []
|
||
|
});
|
||
|
}
|