@@ -2,7 +2,8 @@ import 'package:vine/src/contracts/vine.dart';
22import 'package:vine/src/introspection.dart' ;
33import 'package:vine/src/schema/object/object_schema.dart' ;
44
5- abstract interface class VineSchema <T extends ErrorReporter > implements SchemaIntrospection {
5+ abstract interface class VineSchema <T extends ErrorReporter >
6+ implements SchemaIntrospection {
67 /// Validate the field [field] the field to validate
78 void parse (VineValidationContext ctx, FieldContext field);
89
@@ -63,7 +64,8 @@ abstract interface class BasicSchema<T extends VineSchema> {
6364 T optional ();
6465}
6566
66- abstract interface class VineString implements VineSchema , BasicSchema <VineString > {
67+ abstract interface class VineString
68+ implements VineSchema , BasicSchema <VineString > {
6769 /// Check if the string has a minimum length [value] the minimum length [message] the error message to display
6870 /// ```dart
6971 /// vine.string().minLength(5);
@@ -203,7 +205,8 @@ abstract interface class VineString implements VineSchema, BasicSchema<VineStrin
203205 /// vine.string().confirmed(
204206 /// message: 'The value must be confirmed');
205207 /// ```
206- VineString confirmed ({String ? property, bool include = false , String ? message});
208+ VineString confirmed (
209+ {String ? property, bool include = false , String ? message});
207210
208211 /// Remove leading and trailing whitespace from the string
209212 /// ```dart
@@ -321,9 +324,16 @@ abstract interface class VineString implements VineSchema, BasicSchema<VineStrin
321324 /// message: 'The value must contain only alphabetic characters');
322325 /// ```
323326 VineString regex (RegExp expression, {String ? message});
327+
328+ /// Set the example value for the string [value] the example value
329+ /// ```dart
330+ /// vine.string().example('foo');
331+ /// ```
332+ VineString example (String value);
324333}
325334
326- abstract interface class VineNumber implements VineSchema , BasicSchema <VineNumber > {
335+ abstract interface class VineNumber
336+ implements VineSchema , BasicSchema <VineNumber > {
327337 /// Check if the number is in a range of values [values] the range of values [message] the error message to display
328338 /// ```dart
329339 /// vine.number().range([1, 10]);
@@ -392,15 +402,42 @@ abstract interface class VineNumber implements VineSchema, BasicSchema<VineNumbe
392402 /// You can specify a custom error message
393403 /// ```dart
394404 VineNumber integer ({String ? message});
405+
406+ /// Set the example value for the number [value] the example value
407+ /// ```dart
408+ /// vine.number().example(10);
409+ /// ```
410+ VineNumber example (num value);
395411}
396412
397- abstract interface class VineBoolean implements VineSchema , BasicSchema <VineBoolean > {}
413+ abstract interface class VineBoolean
414+ implements VineSchema , BasicSchema <VineBoolean > {
415+ /// Set the example value for the boolean [value] the example value
416+ /// ```dart
417+ /// vine.boolean().example(true);
418+ /// ```
419+ VineBoolean example (bool value);
420+ }
398421
399- abstract interface class VineAny implements VineSchema , BasicSchema <VineAny > {}
422+ abstract interface class VineAny implements VineSchema , BasicSchema <VineAny > {
423+ /// Set the example value for the any [value] the example value
424+ /// ```dart
425+ /// vine.any().example('foo');
426+ /// ```
427+ VineAny example (dynamic value);
428+ }
400429
401- abstract interface class VineEnum implements VineSchema , BasicSchema <VineEnum > {}
430+ abstract interface class VineEnum <T extends VineEnumerable >
431+ implements VineSchema , BasicSchema <VineEnum <T >> {
432+ /// Set the example value for the enum [value] the example value
433+ /// ```dart
434+ /// vine.enum().example('foo');
435+ /// ```
436+ VineEnum <T > example (T value);
437+ }
402438
403- abstract interface class VineObject implements VineSchema , BasicSchema <VineObject > {
439+ abstract interface class VineObject
440+ implements VineSchema , BasicSchema <VineObject > {
404441 Map <String , VineSchema > get properties;
405442
406443 VineObject merge (VineObjectSchema schema);
@@ -415,7 +452,8 @@ abstract interface class VineGroup implements VineSchema {
415452 /// 'email': vine.string().required().email(),
416453 /// });
417454 /// });
418- VineGroup when (bool Function (Map <String , dynamic > data) fn, Map <String , VineSchema > object);
455+ VineGroup when (bool Function (Map <String , dynamic > data) fn,
456+ Map <String , VineSchema > object);
419457
420458 /// Apply the schema if the condition is not met [fn] the schema to apply
421459 /// ```dart
@@ -432,7 +470,8 @@ abstract interface class VineGroup implements VineSchema {
432470 VineGroup otherwise (Function (VineValidationContext , FieldContext ) fn);
433471}
434472
435- abstract interface class VineArray implements VineSchema , BasicSchema <VineArray > {
473+ abstract interface class VineArray
474+ implements VineSchema , BasicSchema <VineArray > {
436475 /// Check if the array has a minimum length [value] the minimum length [message] the error message to display
437476 /// ```dart
438477 /// vine.array().minLength(5);
@@ -474,7 +513,10 @@ abstract interface class VineArray implements VineSchema, BasicSchema<VineArray>
474513 VineArray unique ({String ? message});
475514}
476515
477- abstract interface class VineUnion implements VineSchema , BasicSchema <VineUnion > {}
516+ abstract interface class VineUnion
517+ implements VineSchema , BasicSchema <VineUnion > {
518+ VineUnion example (dynamic value);
519+ }
478520
479521abstract interface class VineDate implements VineSchema , BasicSchema <VineDate > {
480522 /// Check if the date is before [value] the date to compare [message] the error message to display
@@ -539,4 +581,10 @@ abstract interface class VineDate implements VineSchema, BasicSchema<VineDate> {
539581 /// message: 'The date must be between the start and end date');
540582 /// ```
541583 VineDate betweenFields (String start, String end, {String ? message});
584+
585+ /// Set the example value for the date [value] the example value
586+ /// ```dart
587+ /// vine.date().example(DateTime.now());
588+ /// ```
589+ VineDate example (String value);
542590}
0 commit comments