platform/example/main.dart

28 lines
522 B
Dart
Raw Normal View History

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