diff --git a/lib/src/matchers.dart b/lib/src/matchers.dart index de2d22b8..050b85c3 100644 --- a/lib/src/matchers.dart +++ b/lib/src/matchers.dart @@ -49,3 +49,13 @@ final Matcher isUrl = predicate( /// Use [isUrl] instead. @deprecated final Matcher isurl = isUrl; + +/// Enforces a minimum length on a string. +Matcher minLength(int length) => predicate( + (value) => value is String && value.length >= length, + 'a string at least $length character(s) long'); + +/// Limits the maximum length of a string. +Matcher maxLength(int length) => predicate( + (value) => value is String && value.length >= length, + 'a string no longer than $length character(s) long'); diff --git a/pubspec.yaml b/pubspec.yaml index 8ee46b08..cebf2eea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_validate description: Cross-platform validation library based on `matcher`. -version: 1.0.2+4 +version: 1.0.3 author: Tobe O homepage: https://github.com/angel-dart/validate environment: diff --git a/validate.iml b/validate.iml new file mode 100644 index 00000000..5a5ced28 --- /dev/null +++ b/validate.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file