Publish angel3_validate

This commit is contained in:
thomashii 2021-05-14 19:47:44 +08:00
parent d6dac4b35b
commit 0a15214e53
10 changed files with 35 additions and 46 deletions

View file

@ -1,6 +1,8 @@
# validate
[![Pub](https://img.shields.io/pub/v/angel_validate.svg)](https://pub.dartlang.org/packages/angel_validate)
[![build status](https://travis-ci.org/angel-dart/validate.svg)](https://travis-ci.org/angel-dart/validate)
# angel3_validate
[![version](https://img.shields.io/badge/pub-v2.12.4-brightgreen)](https://pub.dartlang.org/packages/angel3_validate)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/validate/LICENSE)
[Live Example](https://angel-dart.github.io/validate)
@ -33,7 +35,7 @@ For convenience's sake, this library also exports `matcher`.
## Creating a Validator
```dart
import 'package:angel_validate/angel_validate.dart';
import 'package:angel3_validate/angel3_validate.dart';
main() {
var validator = Validator({
@ -144,7 +146,7 @@ main() {
```
# Custom Error Messages
If these are not present, `angel_validate` will *attempt* to generate
If these are not present, `angel3_validate` will *attempt* to generate
a coherent error message on its own.
```dart
@ -286,8 +288,8 @@ main() {
* `filterQuery(only)`: Same as `filterBody`, but operates on `req.query`.
```dart
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_validate/server.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_validate/server.dart';
final Validator echo = Validator({
'message*': (String message) => message.length >= 5
@ -300,7 +302,7 @@ final Validator todo = Validator({
'completed': false
});
main() async {
void main() async {
var app = Angel();
app.chain([validate(echo)]).post('/echo', (req, res) async {

View file

@ -1,6 +1,6 @@
import 'package:angel_validate/angel_validate.dart';
import 'package:angel3_validate/angel3_validate.dart';
main() {
void main() {
var bio = Validator({
'age*': [isInt, greaterThanOrEqualTo(0)],
'birthYear*': isInt,

View file

@ -1,5 +1,5 @@
/// Cross-platform validation library based on `matcher`.
library angel_validate;
library angel3_validate;
export 'package:matcher/matcher.dart';
export 'src/context_aware.dart';

View file

@ -1,13 +1,13 @@
/// Support for using `angel_validate` with the Angel Framework.
library angel_validate.server;
library angel3_validate.server;
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'src/async.dart';
import 'angel_validate.dart';
import 'angel3_validate.dart';
export 'src/async.dart';
export 'angel_validate.dart';
export 'angel3_validate.dart';
/// Auto-parses numbers in `req.bodyAsMap`.
RequestHandler autoParseBody(List<String> fields) {

View file

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_http_exception/angel_http_exception.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_http_exception/angel3_http_exception.dart';
import 'package:matcher/matcher.dart';
import 'context_aware.dart';

View file

@ -1,4 +1,4 @@
import 'package:angel_http_exception/angel_http_exception.dart';
import 'package:angel3_http_exception/angel3_http_exception.dart';
import 'package:matcher/matcher.dart';
import 'context_aware.dart';
import 'context_validator.dart';

View file

@ -1,31 +1,18 @@
name: angel_validate
name: angel3_validate
description: Cross-platform request body validation library based on `matcher`.
version: 4.0.0
homepage: https://github.com/angel-dart/validate
publish_to: none
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/validate
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
angel_framework:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/framework
angel_http_exception:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x_nnbd
path: packages/http_exception
angel3_framework: ^4.0.0
angel3_http_exception: ^3.0.0
matcher: ^0.12.0
dev_dependencies:
#angel_test:
# git:
# url: https://github.com/dukefirehawk/angel.git
# ref: sdk-2.12.x
# path: packages/test
#angel3_test:
build_runner: ^1.11.1
build_web_compilers: ^2.12.2
# logging: ^0.11.0
# mock_request:
logging: ^1.0.1
angel3_mock_request: ^2.0.0
pedantic: ^1.0.0
test: ^1.15.7
test: ^1.17.4

View file

@ -1,4 +1,4 @@
import 'package:angel_validate/angel_validate.dart';
import 'package:angel3_validate/angel3_validate.dart';
import 'package:test/test.dart';
final Validator emailSchema =

View file

@ -1,12 +1,12 @@
import 'dart:async';
import 'dart:convert';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
//import 'package:angel_test/angel_test.dart';
import 'package:angel_validate/server.dart';
import 'package:angel3_validate/server.dart';
import 'package:logging/logging.dart';
import 'package:mock_request/mock_request.dart';
import 'package:angel3_mock_request/angel3_mock_request.dart';
import 'package:test/test.dart';
final Validator echoSchema = Validator({'message*': isString});

View file

@ -1,6 +1,6 @@
import 'dart:html';
import 'package:angel_validate/angel_validate.dart';
import 'package:angel3_validate/angel3_validate.dart';
final $errors = querySelector('#errors') as UListElement?;
final $form = querySelector('#form') as FormElement?;
@ -28,7 +28,7 @@ final Validator formSchema = Validator({
"I told you to leave that field blank, but instead you typed '{{value}}'..."
});
main() {
void main() {
$form!.onSubmit.listen((e) {
e.preventDefault();
$errors!.children.clear();