Skip to content

Commit 0d49dc4

Browse files
committed
feat: rename ErrorReporter to VineErrorReporter and update error
encoding
1 parent 5aaf843 commit 0d49dc4

File tree

7 files changed

+25
-9
lines changed

7 files changed

+25
-9
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,50 @@
1+
## 1.6.2
2+
3+
- Rename `ErrorReporter` to `VineErrorReporter` to prevent collision with `ErrorReporter` class from anither packages
4+
- Change error reporting strategy from `.toString()`to `json.encode()`
5+
16
## 1.6.1
7+
28
- Add `schema.clone()` method to return a new instance of `VineSchema`
39

410
## 1.6.0
5-
- Add `schema.example()` method to decorate OpenApi reporter
11+
12+
- Add `schema.example()` method to decorate OpenApi reporter
613

714
## 1.5.1
15+
816
- Change `Map<String, dynamic>` entry data to `dynamic` in `tryValidate`
917

1018
## 1.5.0
19+
1120
- Added support for all schemas as a high-level entry schema
1221
- Add benchmarks in [`Dartmark`](https://dartmark.dev) website
1322

1423
## 1.4.0
24+
1525
- Add `RegExp` property in phone validation rule
1626

1727
## 1.3.0
28+
1829
- Add missing `VineNotSameAsRule` implementation
1930
- Implement `VineRegexRule` validation rule
2031
- Add related [Dev.to](https://dev.to/baptiste_parmantier/validate-your-data-structures-with-vine-in-your-dart-projects-111p) article
2132

2233
## 1.2.0
34+
2335
- Move rules from handlers to dedicated classes
2436
- Implement OpenAPI reporter
2537

2638
## 1.1.0
39+
2740
- Implement `VineBasics` validation rules
2841
- Implement `VineGroup` validation rules
2942
- Implement `VineDate` validation rules
3043
- Optimize validation algorithm
3144
- Enhance performance of the library, `~22 000 000` -> `~29 500 000` ops/sec (`+34%`)
3245

3346
## 1.0.0
47+
3448
**Initial release**
3549

3650
- Implement the basic functionality of the library

lib/src/contracts/schema.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:vine/src/contracts/vine.dart';
22
import 'package:vine/src/introspection.dart';
33
import 'package:vine/src/schema/object/object_schema.dart';
44

5-
abstract interface class VineSchema<T extends ErrorReporter>
5+
abstract interface class VineSchema<T extends VineErrorReporter>
66
implements SchemaIntrospection {
77
/// Validate the field [field] the field to validate
88
void parse(VineValidationContext ctx, FieldContext field);

lib/src/contracts/vine.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
abstract interface class ErrorReporter {
1+
abstract interface class VineErrorReporter {
22
List<Map<String, Object>> get errors;
33

44
abstract bool hasError;
@@ -17,7 +17,7 @@ abstract interface class ErrorReporter {
1717

1818
abstract interface class ValidatorContract {}
1919

20-
abstract interface class VineValidationContext<T extends ErrorReporter> {
20+
abstract interface class VineValidationContext<T extends VineErrorReporter> {
2121
T get errorReporter;
2222

2323
dynamic get data;

lib/src/error_reporter.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import 'dart:convert';
2+
13
import 'package:vine/src/contracts/vine.dart';
24
import 'package:vine/src/exceptions/validation_exception.dart';
35
import 'package:vine/src/mapped_errors.dart';
46

5-
class SimpleErrorReporter implements ErrorReporter {
7+
class SimpleErrorReporter implements VineErrorReporter {
68
final Map<String, String> _errorMessages;
79

810
@override
@@ -37,7 +39,7 @@ class SimpleErrorReporter implements ErrorReporter {
3739

3840
@override
3941
Exception createError(Object message) {
40-
return ValidationException(message.toString());
42+
return ValidationException(json.encode(message));
4143
}
4244

4345
@override

lib/src/field.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:vine/src/contracts/vine.dart';
22

3-
final class ValidatorContext<T extends ErrorReporter>
3+
final class ValidatorContext<T extends VineErrorReporter>
44
implements VineValidationContext<T> {
55
@override
66
final T errorReporter;

lib/src/vine.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import 'package:vine/src/schema/string_schema.dart';
2828
import 'package:vine/src/schema/union_schema.dart';
2929

3030
final class Vine {
31-
ErrorReporter Function(Map<String, String> errors) errorReporter =
31+
VineErrorReporter Function(Map<String, String> errors) errorReporter =
3232
SimpleErrorReporter.new;
3333

3434
VineObject object(Map<String, VineSchema> payload, {String? message}) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: vine
22
description: Vine is a robust, typed validation library for Dart/Flutter, designed to simplify and secure data management in applications
3-
version: 1.6.1
3+
version: 1.6.2
44
repository: https://github.com/LeadcodeDev/vine
55

66
platforms:

0 commit comments

Comments
 (0)