-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63c9154
commit 0689f65
Showing
5 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:lucid_validation/lucid_validation.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../mocks/mocks.dart'; | ||
|
||
void main() { | ||
test('is not null validation ...', () { | ||
final validator = TestLucidValidator<UserModel>(); | ||
validator | ||
.ruleFor((e) => e.description, key: 'description') // | ||
.isNotNull(); | ||
|
||
final user = UserModel(); | ||
|
||
final result = validator.validate(user); | ||
|
||
expect(result.isValid, false); | ||
|
||
expect(result.errors.length, 1); | ||
|
||
final error = result.errors.first; | ||
|
||
expect(error.message, r"'description' must not be null."); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:lucid_validation/lucid_validation.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../mocks/mocks.dart'; | ||
|
||
void main() { | ||
test('is null validation ...', () { | ||
final validator = TestLucidValidator<UserModel>(); | ||
|
||
validator | ||
.ruleFor((e) => e.description, key: 'description') // | ||
.isNull(); | ||
|
||
final user = UserModel()..description = 'description'; | ||
|
||
final result = validator.validate(user); | ||
|
||
expect(result.isValid, false); | ||
|
||
expect(result.errors.length, 1); | ||
|
||
final error = result.errors.first; | ||
|
||
expect(error.message, r"'description' must be null."); | ||
}); | ||
} |