commas
This commit is contained in:
parent
72d1e1d2bf
commit
2ffd607230
5 changed files with 36 additions and 24 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -27,3 +27,5 @@ doc/api/
|
|||
pubspec.lock
|
||||
|
||||
log.txt
|
||||
|
||||
.idea
|
|
@ -1,5 +1,5 @@
|
|||
# validate
|
||||
[![version 1.0.1](https://img.shields.io/badge/pub-v1.0.1-brightgreen.svg)](https://pub.dartlang.org/packages/angel_validate)
|
||||
[![version 1.0.2](https://img.shields.io/badge/pub-v1.0.2-brightgreen.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)
|
||||
|
||||
[Live Example](https://angel-dart.github.io/validate)
|
||||
|
|
|
@ -61,7 +61,8 @@ class Validator extends Matcher {
|
|||
final List<String> requiredFields = [];
|
||||
|
||||
void _importSchema(Map<String, dynamic> schema) {
|
||||
for (var key in schema.keys) {
|
||||
for (var keys in schema.keys) {
|
||||
for (var key in keys.split(',')) {
|
||||
var fieldName = key
|
||||
.replaceAll(_asterisk, '')
|
||||
.replaceAll(_forbidden, '')
|
||||
|
@ -75,7 +76,8 @@ class Validator extends Matcher {
|
|||
requiredFields.add(fieldName);
|
||||
}
|
||||
|
||||
Iterable iterable = schema[key] is Iterable ? schema[key] : [schema[key]];
|
||||
Iterable iterable =
|
||||
schema[keys] is Iterable ? schema[keys] : [schema[keys]];
|
||||
|
||||
for (var rule in iterable) {
|
||||
if (rule is Matcher) {
|
||||
|
@ -89,6 +91,7 @@ class Validator extends Matcher {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Validator.empty();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: angel_validate
|
||||
description: Cross-platform validation library based on `matcher`.
|
||||
version: 1.0.1
|
||||
version: 1.0.2
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/validate
|
||||
environment:
|
||||
|
|
|
@ -7,7 +7,8 @@ final Validator emailSchema = new Validator({'to': isEmail},
|
|||
final Validator todoSchema = new Validator({
|
||||
'id': [isInt, isPositive],
|
||||
'text*': isString,
|
||||
'completed*': isBool
|
||||
'completed*': isBool,
|
||||
'foo,bar': [isTrue]
|
||||
}, defaultValues: {
|
||||
'completed': false
|
||||
});
|
||||
|
@ -33,4 +34,10 @@ main() {
|
|||
var only = filter(inputData, ['foo']);
|
||||
expect(only, equals({'foo': 'bar'}));
|
||||
});
|
||||
|
||||
test('comma in schema', () {
|
||||
expect(todoSchema.rules.keys, allOf(contains('foo'), contains('bar')));
|
||||
expect([todoSchema.rules['foo'].first, todoSchema.rules['bar'].first],
|
||||
everyElement(predicate((x) => x == isTrue)));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue