@@ -15,33 +15,33 @@ class GenExtractor {
1515 return macro if (value != null ) $e else null ;
1616
1717 static public function string ()
18- return macro if (!Std .is (value , String )) throw ' The value ` ' + value + ' ` should be String ' else value ;
18+ return macro if (!Std .is (value , String )) throw tink.validation. Error . UnexpectedType ( String , value ) else value ;
1919
2020 static public function int ()
21- return macro if (!Std .is (value , Int )) throw ' The value ` ' + value + ' ` should be Int ' else value ;
21+ return macro if (!Std .is (value , Int )) throw tink.validation. Error . UnexpectedType ( Int , value ) else value ;
2222
2323 static public function float ()
24- return macro if (!Std .is (value , Float )) throw ' The value ` ' + value + ' ` should be Float ' else value ;
24+ return macro if (!Std .is (value , Float )) throw tink.validation. Error . UnexpectedType ( Float , value ) else value ;
2525
2626 static public function bool ()
27- return macro if (!Std .is (value , Bool )) throw ' The value ` ' + value + ' ` should be Bool ' else value ;
27+ return macro if (!Std .is (value , Bool )) throw tink.validation. Error . UnexpectedType ( Bool , value ) else value ;
2828
2929 static public function date ()
30- return macro if (!Std .is (value , Date )) throw ' The value ` ' + value + ' ` should be Date ' else value ;
30+ return macro if (!Std .is (value , Date )) throw tink.validation. Error . UnexpectedType ( Date , value ) else value ;
3131 // TODO: should make a copy? i.e. `Date.fromTime(value.getTime())`
3232
3333 static public function bytes ()
34- return macro if (!Std .is (value , Bytes )) throw ' The value ` ' + value + ' ` should be Bytes ' else value ;
34+ return macro if (!Std .is (value , haxe . io . Bytes )) throw tink.validation. Error . UnexpectedType ( haxe.io. Bytes , value ) else value ;
3535
3636 static public function map (k , v )
37- return macro if (!Std .is (value , Map )) throw ' The value ` ' + value + ' ` should be Map ' else value ;
37+ return macro if (!Std .is (value , Map )) throw tink.validation. Error . UnexpectedType ( Map , value ) else value ;
3838
3939 static public function anon (fields : Array <FieldInfo >, ct )
4040 return (macro function (value : $ct ) {
4141 var __ret : Dynamic = {};
4242 $b {[for (f in fields ) {
4343 var name = f .name ;
44- var assert = f .optional ? macro null : macro if (! Reflect .hasField (value , $v {name })) throw $v {' Field ` ${ f . name }` should not be null ' } ;
44+ var assert = f .optional ? macro null : macro if (! Reflect .hasField (value , $v {name })) throw throw tink.validation. Error . MissingField ( $v {name }) ;
4545 macro {
4646 $assert ;
4747 var value = value .$name ;
@@ -54,7 +54,7 @@ class GenExtractor {
5454 static public function array (e : Expr )
5555 {
5656 return macro {
57- if (! Std .is (value , Array )) throw ' The value ` ' + value + ' ` should be Array ' ;
57+ if (! Std .is (value , Array )) throw tink.validation. Error . UnexpectedType ( Array , value ) ;
5858 [for (value in (value : Array <Dynamic >)) $e ];
5959 }
6060 }
@@ -68,7 +68,7 @@ class GenExtractor {
6868 ret ;
6969 default : throw ' assert' ;
7070 }
71- return macro if (! Std .is (value , $p {name })) throw ' The value ` ' + value + ' ` should be an EnumValue ' else value ;
71+ return macro if (! Std .is (value , $p {name })) throw tink.validation. Error . UnexpectedType ($ p { name }, value ) else value ;
7272 }
7373
7474 static public function dyn (_ , _ )
0 commit comments