@@ -26,7 +26,6 @@ import type {
2626 RegularLayout ,
2727 PanelLayout ,
2828 CardLayout ,
29- DeepPartial ,
3029} from '../../../types' ;
3130import { unlock } from '../../../lock-unlock' ;
3231
@@ -427,75 +426,72 @@ const ValidationComponent = ( {
427426 password : 'secretpassword123' ,
428427 } ) ;
429428
430- const customTextRule = ( value : DeepPartial < ValidatedItem > ) => {
431- if ( value . text && ! / ^ [ a - z A - Z ] + $ / . test ( value . text ) ) {
429+ const customTextRule = ( value : ValidatedItem ) => {
430+ if ( ! / ^ [ a - z A - Z ] + $ / . test ( value . text ) ) {
432431 return 'Value must only contain letters and spaces.' ;
433432 }
434433
435434 return null ;
436435 } ;
437- const customTextareaRule = ( value : DeepPartial < ValidatedItem > ) => {
438- if ( value . textarea && ! / ^ [ a - z A - Z ] + $ / . test ( value . textarea ) ) {
436+ const customTextareaRule = ( value : ValidatedItem ) => {
437+ if ( ! / ^ [ a - z A - Z ] + $ / . test ( value . textarea ) ) {
439438 return 'Value must only contain letters and spaces.' ;
440439 }
441440
442441 return null ;
443442 } ;
444- const customEmailRule = ( value : DeepPartial < ValidatedItem > ) => {
445- if (
446- value . email &&
447- ! / ^ [ a - z A - Z 0 - 9 . _ % + - ] + @ e x a m p l e \. c o m $ / . test ( value . email )
448- ) {
443+ const customEmailRule = ( value : ValidatedItem ) => {
444+ if ( ! / ^ [ a - z A - Z 0 - 9 . _ % + - ] + @ e x a m p l e \. c o m $ / . test ( value . email ) ) {
449445 return 'Email address must be from @example.com domain.' ;
450446 }
451447
452448 return null ;
453449 } ;
454- const customTelephoneRule = ( value : DeepPartial < ValidatedItem > ) => {
455- if ( value . telephone && ! / ^ \+ 3 0 \d { 10 } $ / . test ( value . telephone ) ) {
450+ const customTelephoneRule = ( value : ValidatedItem ) => {
451+ if ( ! / ^ \+ 3 0 \d { 10 } $ / . test ( value . telephone ) ) {
456452 return 'Telephone number must start with +30 and have 10 digits after.' ;
457453 }
458454
459455 return null ;
460456 } ;
461- const customUrlRule = ( value : DeepPartial < ValidatedItem > ) => {
462- if ( value . url && ! / ^ h t t p s : \/ \/ e x a m p l e \. c o m $ / . test ( value . url ) ) {
457+ const customUrlRule = ( value : ValidatedItem ) => {
458+ if ( ! / ^ h t t p s : \/ \/ e x a m p l e \. c o m $ / . test ( value . url ) ) {
463459 return 'URL must be from https://example.com domain.' ;
464460 }
465461
466462 return null ;
467463 } ;
468- const customColorRule = ( value : DeepPartial < ValidatedItem > ) => {
469- if ( value . color && ! / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( value . color ) ) {
464+ const customColorRule = ( value : ValidatedItem ) => {
465+ if ( ! / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( value . color ) ) {
470466 return 'Color must be a valid hex format (e.g., #ff6600).' ;
471467 }
472468
473469 return null ;
474470 } ;
475- const customIntegerRule = ( value : DeepPartial < ValidatedItem > ) => {
476- if ( value . integer && value . integer % 2 !== 0 ) {
471+ const customIntegerRule = ( value : ValidatedItem ) => {
472+ if ( value . integer % 2 !== 0 ) {
477473 return 'Integer must be an even number.' ;
478474 }
479475
480476 return null ;
481477 } ;
482478
483- const customPasswordRule = ( value : DeepPartial < ValidatedItem > ) => {
484- if ( value . password && value . password . length < 8 ) {
479+ const customPasswordRule = ( value : ValidatedItem ) => {
480+ if ( value . password . length < 8 ) {
485481 return 'Password must be at least 8 characters long.' ;
486482 }
487- if ( value . password && ! / [ A - Z ] / . test ( value . password ) ) {
483+ if ( ! / [ A - Z ] / . test ( value . password ) ) {
488484 return 'Password must contain at least one uppercase letter.' ;
489485 }
490- if ( value . password && ! / [ 0 - 9 ] / . test ( value . password ) ) {
486+ if ( ! / [ 0 - 9 ] / . test ( value . password ) ) {
491487 return 'Password must contain at least one number.' ;
492488 }
493489
494490 return null ;
495491 } ;
496492
497493 const maybeCustomRule = (
498- rule : ( item : DeepPartial < ValidatedItem > ) => null | string
494+ rule : ( item : ValidatedItem ) => null | string
499495 ) => {
500496 return custom ? rule : undefined ;
501497 } ;
0 commit comments