bump to 2.0.0-alpha
This commit is contained in:
parent
39944f4302
commit
95106b6271
2 changed files with 16 additions and 16 deletions
|
@ -10,7 +10,7 @@ export 'src/async.dart';
|
||||||
export 'angel_validate.dart';
|
export 'angel_validate.dart';
|
||||||
|
|
||||||
/// Auto-parses numbers in `req.body`.
|
/// Auto-parses numbers in `req.body`.
|
||||||
RequestMiddleware autoParseBody(List<String> fields) {
|
RequestHandler autoParseBody(List<String> fields) {
|
||||||
return (RequestContext req, res) async {
|
return (RequestContext req, res) async {
|
||||||
(await req.lazyBody()).addAll(autoParse(req.body, fields));
|
(await req.lazyBody()).addAll(autoParse(req.body, fields));
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,7 +18,7 @@ RequestMiddleware autoParseBody(List<String> fields) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Auto-parses numbers in `req.query`.
|
/// Auto-parses numbers in `req.query`.
|
||||||
RequestMiddleware autoParseQuery(List<String> fields) {
|
RequestHandler autoParseQuery(List<String> fields) {
|
||||||
return (RequestContext req, res) async {
|
return (RequestContext req, res) async {
|
||||||
req.query.addAll(autoParse(req.query, fields));
|
req.query.addAll(autoParse(req.query, fields));
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,7 +26,7 @@ RequestMiddleware autoParseQuery(List<String> fields) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Filters unwanted data out of `req.body`.
|
/// Filters unwanted data out of `req.body`.
|
||||||
RequestMiddleware filterBody(Iterable<String> only) {
|
RequestHandler filterBody(Iterable<String> only) {
|
||||||
return (RequestContext req, res) async {
|
return (RequestContext req, res) async {
|
||||||
var filtered = filter(await req.lazyBody(), only);
|
var filtered = filter(await req.lazyBody(), only);
|
||||||
req.body
|
req.body
|
||||||
|
@ -37,7 +37,7 @@ RequestMiddleware filterBody(Iterable<String> only) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Filters unwanted data out of `req.query`.
|
/// Filters unwanted data out of `req.query`.
|
||||||
RequestMiddleware filterQuery(Iterable<String> only) {
|
RequestHandler filterQuery(Iterable<String> only) {
|
||||||
return (RequestContext req, res) async {
|
return (RequestContext req, res) async {
|
||||||
var filtered = filter(req.query, only);
|
var filtered = filter(req.query, only);
|
||||||
req.query
|
req.query
|
||||||
|
@ -49,11 +49,11 @@ RequestMiddleware filterQuery(Iterable<String> only) {
|
||||||
|
|
||||||
/// Validates the data in `req.body`, and sets the body to
|
/// Validates the data in `req.body`, and sets the body to
|
||||||
/// filtered data before continuing the response.
|
/// filtered data before continuing the response.
|
||||||
RequestMiddleware validate(Validator validator,
|
RequestHandler validate(Validator validator,
|
||||||
{String errorMessage: 'Invalid data.'}) {
|
{String errorMessage: 'Invalid data.'}) {
|
||||||
return (RequestContext req, res) async {
|
return (RequestContext req, res) async {
|
||||||
var result =
|
var result =
|
||||||
await asyncApplyValidator(validator, await req.lazyBody(), req.app);
|
await asyncApplyValidator(validator, await req.parseBody(), req.app);
|
||||||
|
|
||||||
if (result.errors.isNotEmpty) {
|
if (result.errors.isNotEmpty) {
|
||||||
throw new AngelHttpException.badRequest(
|
throw new AngelHttpException.badRequest(
|
||||||
|
@ -70,10 +70,10 @@ RequestMiddleware validate(Validator validator,
|
||||||
|
|
||||||
/// Validates the data in `req.query`, and sets the query to
|
/// Validates the data in `req.query`, and sets the query to
|
||||||
/// filtered data before continuing the response.
|
/// filtered data before continuing the response.
|
||||||
RequestMiddleware validateQuery(Validator validator,
|
RequestHandler validateQuery(Validator validator,
|
||||||
{String errorMessage: 'Invalid data.'}) {
|
{String errorMessage: 'Invalid data.'}) {
|
||||||
return (RequestContext req, res) async {
|
return (RequestContext req, res) async {
|
||||||
var result = await asyncApplyValidator(validator, req.query, req.app);
|
var result = await asyncApplyValidator(validator, await req.parseQuery(), req.app);
|
||||||
|
|
||||||
if (result.errors.isNotEmpty) {
|
if (result.errors.isNotEmpty) {
|
||||||
throw new AngelHttpException.badRequest(
|
throw new AngelHttpException.badRequest(
|
||||||
|
@ -94,7 +94,7 @@ HookedServiceEventListener validateEvent(Validator validator,
|
||||||
{String errorMessage: 'Invalid data.'}) {
|
{String errorMessage: 'Invalid data.'}) {
|
||||||
return (HookedServiceEvent e) async {
|
return (HookedServiceEvent e) async {
|
||||||
var result = await asyncApplyValidator(
|
var result = await asyncApplyValidator(
|
||||||
validator, e.data as Map, (e.request?.app ?? e.service.app) as Angel);
|
validator, e.data as Map, (e.request?.app ?? e.service.app));
|
||||||
|
|
||||||
if (result.errors.isNotEmpty) {
|
if (result.errors.isNotEmpty) {
|
||||||
throw new AngelHttpException.badRequest(
|
throw new AngelHttpException.badRequest(
|
||||||
|
|
14
pubspec.yaml
14
pubspec.yaml
|
@ -1,17 +1,17 @@
|
||||||
name: angel_validate
|
name: angel_validate
|
||||||
description: Cross-platform validation library based on `matcher`.
|
description: Cross-platform validation library based on `matcher`.
|
||||||
version: 1.0.5-beta
|
version: 2.0.0-alpha
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/validate
|
homepage: https://github.com/angel-dart/validate
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=1.19.0 <3.0.0"
|
sdk: ">=2.0.0-dev <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ^1.0.0-dev
|
angel_framework: ^2.0.0-alpha
|
||||||
angel_http_exception: ^1.0.0
|
angel_http_exception: ^1.0.0
|
||||||
matcher: ^0.12.0
|
matcher: ^0.12.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
angel_test: ^1.0.0-dev
|
#angel_test: ^1.0.0-dev
|
||||||
browser: ^0.10.0
|
build_runner: ^0.10.0
|
||||||
dart2_constant: ^1.0.0
|
build_web_compilers: ^0.4.0
|
||||||
logging: ^0.11.0
|
logging: ^0.11.0
|
||||||
test: ^0.12.18
|
test: ^1.0.0
|
Loading…
Reference in a new issue