Skip to content

Commit

Permalink
Added NumberRule which checks if the value is a valid number or not
Browse files Browse the repository at this point in the history
Added `MinRule` which checks if the value is greater a specific number or not
Added `MaxRule` which checks if the value is less than a specific number or not
`MinLengthRule`, `MaxLengthRule` now supports List and Map
`RequiredRule` now supports List, Map and other Data types. In case of other Data type, nullability of the value is tested
Update Project Style
Migrate Example to AndroidX
Update Docs Dependencies

Merge branch 'release/0.5.0'
  • Loading branch information
ibrahim-mubarak committed Mar 30, 2021
2 parents 3c34ae2 + 0565d45 commit c942753
Show file tree
Hide file tree
Showing 40 changed files with 3,265 additions and 2,259 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [v0.5.0]
### Added
Added `NumberRule` which checks if the value is a valid number or not
Added `MinRule` which checks if the value is greater a specific number or not
Added `MaxRule` which checks if the value is less than a specific number or not

### Changed
`MinLengthRule`, `MaxLengthRule` now supports List and Map
`RequiredRule` now supports List, Map and other Data types. In case of other Data type, nullability of the value is tested
Update Project Style
Migrate Example to AndroidX
Update Docs Dependencies

### Removed
- `Validator.build()` deprecated in [v0.4.0+2]

## [v0.4.0+2]

### Added
Expand Down Expand Up @@ -38,6 +54,7 @@

Initial Release

[v0.5.0]: https://github.com/flrx/validator/compare/v0.5.0...v0.4.0+2
[v0.4.0+2]: https://github.com/flrx/validator/compare/v0.4.0+2...v0.3.0
[v0.3.0]: https://github.com/flrx/validator/compare/v0.3.0...v0.2.0
[v0.2.0]: https://github.com/flrx/validator/compare/v0.2.0...v0.1.0
Expand Down
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_specify_types
- annotate_overrides
- avoid_bool_literals_in_conditional_expressions
- close_sinks
Expand Down
56 changes: 55 additions & 1 deletion doc/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ Flrx Validator comes with lot of built-in rules:
### RequiredRule

This `Rule` validates if the input provided to it is not empty.
* It explicitly supports String, Map and Iterable.
* It implicitly supports any type which has the length getter.
* For any other type, the nullability of the value is tested,

```dart
Validator<String>(rules: [RequiredRule()])
Validator<String>(rules: [RequiredRule()])
```

**Output**
Expand All @@ -27,6 +30,8 @@ Entity is required
### MaxLengthRule

This `Rule` validates if the input's length is less than the max limit.
* It explicitly supports String, Map and Iterable.
* It implicitly supports any type which has the length getter.

```dart
Validator<String>(rules: [MaxLengthRule(20)])
Expand All @@ -38,6 +43,12 @@ Validator<String>(rules: [MaxLengthRule(20)])
Entity should be less than 20 characters
```

To use it with your custom types, initialize the rule with dynamic Type.

```dart
Validator<MyCustomType>(rules: [MaxLengthRule<dynamic>(20)])
```

### MinLengthRule

This `Rule` validates if the input's length is more than the min limit.
Expand All @@ -51,6 +62,49 @@ Validator<String>(rules: [MinLengthRule(6)])
```
Entity should be more than 6 characters
```
The supported types and usage are similar to `MaxLengthRule`

### NumberRule

This `Rule` validates if the input is a number.

```dart
Validator<String>(rules: [NumberRule()])
```

**Output**

```
Value is not a number
```

### MinRule

This `Rule` validates if the input is a number and is greater than a specific number.

```dart
Validator<String>(rules: [MinRule(20)])
```

**Output**

```
Value should be greater than 20
```

### MaxRule

This `Rule` validates if the input is a number.

```dart
Validator<String>(rules: [MaxRule(100)])
```

**Output**

```
Value should be lesser than 100
```

### RegexRule

Expand Down
Loading

0 comments on commit c942753

Please sign in to comment.