@@ -205,12 +205,29 @@ export default defineInstrument({
205205 numberSelect : z . union ( [ z . literal ( 1 ) , z . literal ( 2 ) , z . literal ( 3 ) ] ) ,
206206 numberSlider : z . number ( ) ,
207207 stringInput : z . string ( ) ,
208- stringPassword : z
209- . string ( )
210- . regex (
211- / " ^ (? = .* [ A - Z a - z ] ) (? = .* \d ) [ A - Z a - z \d ] { 8 , } $ " / ,
212- 'Password must contain eight or more characters and at least one letter and one number'
213- ) ,
208+ stringPassword : z . string ( ) . superRefine ( ( arg , ctx ) => {
209+ if ( arg . length < 8 ) {
210+ ctx . addIssue ( {
211+ code : z . ZodIssueCode . custom ,
212+ message : 'Password must contain at least 8 characters'
213+ } ) ;
214+ } else if ( ! / \d + / . test ( arg ) ) {
215+ ctx . addIssue ( {
216+ code : z . ZodIssueCode . custom ,
217+ message : 'Password must contain at least 1 number'
218+ } ) ;
219+ } else if ( ! / [ a - z ] + / . test ( arg ) ) {
220+ ctx . addIssue ( {
221+ code : z . ZodIssueCode . custom ,
222+ message : 'Password must contain at least 1 lower case letter'
223+ } ) ;
224+ } else if ( ! / [ A - Z ] + / . test ( arg ) ) {
225+ ctx . addIssue ( {
226+ code : z . ZodIssueCode . custom ,
227+ message : 'Password must contain at least 1 upper case letter'
228+ } ) ;
229+ }
230+ } ) ,
214231 stringRadio : z . enum ( [ 'a' , 'b' , 'c' ] ) ,
215232 stringSelect : z . enum ( [ 'a' , 'b' , 'c' ] ) ,
216233 stringTextArea : z . string ( ) ,
0 commit comments