From 6338abd79e5a0ac64edc745991de876e6c7cc5e5 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Mon, 4 May 2020 12:42:24 -0400 Subject: [PATCH] validate: update readme, do not export pkg:matcher --- packages/validate/README.md | 15 ++++++++++----- packages/validate/example/main.dart | 4 +++- packages/validate/lib/angel_validate.dart | 7 +++++-- packages/validate/lib/without_matcher.dart | 5 ----- 4 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 packages/validate/lib/without_matcher.dart diff --git a/packages/validate/README.md b/packages/validate/README.md index 82909f11..9b86e68c 100644 --- a/packages/validate/README.md +++ b/packages/validate/README.md @@ -3,12 +3,10 @@ [![build status](https://travis-ci.org/angel-dart/validate.svg)](https://travis-ci.org/angel-dart/validate) Strongly-typed form handlers and validators for Angel. +Version `3.x` is a major improvement over `2.x`, though it does include breaking changes. -Validation library based on the `matcher` library, with Angel support. -Why re-invent the wheel, when you can use the same validators you already -use for tests? - -For convenience's sake, this library also exports `matcher`. +`package:angel_validate` allows you to easily sanitize incoming data, and to deserialize +that data into Dart classes (usually using `package:angel_serialize`). # Field The basic unit is the `Field` class, which is a type-safe way to read @@ -23,6 +21,13 @@ app.get('/hello', (req, res) async { }); ``` +A `Field` can also use `Matcher` objects from `package:matcher` (which you may recognize from +its usage in `package:test`): + +```dart +var positiveNumberField = IntField('pos_num').match([isPositive]); +``` + There are several included field types: * `TextField` * `BoolField` diff --git a/packages/validate/example/main.dart b/packages/validate/example/main.dart index 8941432c..858734ad 100644 --- a/packages/validate/example/main.dart +++ b/packages/validate/example/main.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:angel_framework/angel_framework.dart'; import 'package:angel_framework/http.dart'; import 'package:angel_validate/angel_validate.dart'; @@ -5,7 +7,7 @@ import 'package:http_parser/http_parser.dart'; import 'package:logging/logging.dart'; import 'package:pretty_logging/pretty_logging.dart'; -main() async { +Future main() async { Logger.root ..level = Level.ALL ..onRecord.listen(prettyLog); diff --git a/packages/validate/lib/angel_validate.dart b/packages/validate/lib/angel_validate.dart index 4096121b..8a054d9c 100644 --- a/packages/validate/lib/angel_validate.dart +++ b/packages/validate/lib/angel_validate.dart @@ -1,2 +1,5 @@ -export 'package:matcher/matcher.dart'; -export 'without_matcher.dart'; +export 'src/common_fields.dart'; +export 'src/field.dart'; +export 'src/form.dart'; +export 'src/form_renderer.dart'; +export 'src/matchers.dart'; diff --git a/packages/validate/lib/without_matcher.dart b/packages/validate/lib/without_matcher.dart deleted file mode 100644 index 8a054d9c..00000000 --- a/packages/validate/lib/without_matcher.dart +++ /dev/null @@ -1,5 +0,0 @@ -export 'src/common_fields.dart'; -export 'src/field.dart'; -export 'src/form.dart'; -export 'src/form_renderer.dart'; -export 'src/matchers.dart';