@@ -41,38 +41,95 @@ func TestUTF8LengthBetweenValidator(t *testing.T) {
4141 minLength : 2 ,
4242 maxLength : 3 ,
4343 },
44+ "valid unknown prefix single byte characters" : {
45+ val : types .StringUnknown ().RefineWithPrefix ("ok" ),
46+ minLength : 2 ,
47+ maxLength : 3 ,
48+ },
49+ // Even if the refinement is too short, it's possible the final value could be longer, so no validation error.
50+ "valid unknown prefix single byte characters - too short" : {
51+ val : types .StringUnknown ().RefineWithPrefix ("ok" ),
52+ minLength : 5 ,
53+ maxLength : 6 ,
54+ },
4455 "valid mixed byte characters" : {
4556 // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
4657 val : types .StringValue ("test⇄test" ),
4758 minLength : 8 ,
4859 maxLength : 9 ,
4960 },
61+ "valid unknown prefix mixed byte characters" : {
62+ // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
63+ val : types .StringUnknown ().RefineWithPrefix ("test⇄test" ),
64+ minLength : 8 ,
65+ maxLength : 9 ,
66+ },
67+ // Even if the refinement is too short, it's possible the final value could be longer, so no validation error.
68+ "valid unknown prefix mixed byte characters - too short" : {
69+ // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
70+ val : types .StringUnknown ().RefineWithPrefix ("test⇄test" ),
71+ minLength : 12 ,
72+ maxLength : 14 ,
73+ },
5074 "valid multiple byte characters" : {
5175 // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
5276 val : types .StringValue ("⇄" ),
5377 minLength : 1 ,
5478 maxLength : 1 ,
5579 },
80+ "valid unknown prefix multiple byte characters" : {
81+ // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
82+ val : types .StringUnknown ().RefineWithPrefix ("⇄" ),
83+ minLength : 1 ,
84+ maxLength : 1 ,
85+ },
86+ // Even if the refinement is too short, it's possible the final value could be longer, so no validation error.
87+ "valid unknown prefix multiple byte characters - too short" : {
88+ // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
89+ val : types .StringUnknown ().RefineWithPrefix ("⇄" ),
90+ minLength : 3 ,
91+ maxLength : 4 ,
92+ },
5693 "invalid single byte characters" : {
5794 val : types .StringValue ("ok" ),
5895 minLength : 1 ,
5996 maxLength : 1 ,
6097 expectError : true ,
6198 },
99+ "invalid unknown prefix single byte characters" : {
100+ val : types .StringUnknown ().RefineWithPrefix ("ok" ),
101+ minLength : 1 ,
102+ maxLength : 1 ,
103+ expectError : true ,
104+ },
62105 "invalid mixed byte characters" : {
63106 // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
64107 val : types .StringValue ("test⇄test" ),
65108 minLength : 8 ,
66109 maxLength : 8 ,
67110 expectError : true ,
68111 },
112+ "invalid unknown prefix mixed byte characters" : {
113+ // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
114+ val : types .StringUnknown ().RefineWithPrefix ("test⇄test" ),
115+ minLength : 8 ,
116+ maxLength : 8 ,
117+ expectError : true ,
118+ },
69119 "invalid multiple byte characters" : {
70120 // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
71121 val : types .StringValue ("⇄⇄" ),
72122 minLength : 1 ,
73123 maxLength : 1 ,
74124 expectError : true ,
75125 },
126+ "invalid unknown prefix multiple byte characters" : {
127+ // Rightwards Arrow Over Leftwards Arrow (U+21C4; 3 bytes)
128+ val : types .StringUnknown ().RefineWithPrefix ("⇄⇄" ),
129+ minLength : 1 ,
130+ maxLength : 1 ,
131+ expectError : true ,
132+ },
76133 "invalid validator usage - minLength < 0" : {
77134 val : types .StringValue ("ok" ),
78135 minLength : - 1 ,
0 commit comments