File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -99,3 +99,38 @@ func TestValidationAny(t *testing.T) {
9999 },
100100 })
101101}
102+
103+ func TestToDiagFunc (t * testing.T ) {
104+ runDiagTestCases (t , []diagTestCase {
105+ {
106+ val : 43 ,
107+ f : ToDiagFunc (Any (
108+ IntAtLeast (42 ),
109+ IntAtMost (5 ),
110+ )),
111+ },
112+ {
113+ val : "foo" ,
114+ f : ToDiagFunc (All (
115+ StringLenBetween (1 , 10 ),
116+ StringIsNotWhiteSpace ,
117+ )),
118+ },
119+ {
120+ val : 7 ,
121+ f : ToDiagFunc (Any (
122+ IntAtLeast (42 ),
123+ IntAtMost (5 ),
124+ )),
125+ expectedErr : regexp .MustCompile ("expected [\\ w]+ to be at least \\ (42\\ ), got 7" ),
126+ },
127+ {
128+ val : 7 ,
129+ f : ToDiagFunc (Any (
130+ IntAtLeast (42 ),
131+ IntAtMost (5 ),
132+ )),
133+ expectedErr : regexp .MustCompile ("expected [\\ w]+ to be at most \\ (5\\ ), got 7" ),
134+ },
135+ })
136+ }
You can’t perform that action at this time.
0 commit comments