Skip to content

Commit

Permalink
refactor: validator package bundle size improvements (#8402)
Browse files Browse the repository at this point in the history
  • Loading branch information
frosso authored Mar 18, 2024
1 parent be837a1 commit 63ba2e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog/refactor-validator-bundle-size
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

refactor: validator package bundle size improvements
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import validator from 'validator';
import isEmail from 'validator/lib/isEmail';
import { __ } from '@wordpress/i18n';

const useExpressCheckoutProductHandler = ( api ) => {
Expand Down Expand Up @@ -49,7 +49,7 @@ const useExpressCheckoutProductHandler = ( api ) => {
if (
! data.wc_gc_giftcard_to_multiple
.split( ',' )
.every( ( email ) => validator.isEmail( email.trim() ) )
.every( ( email ) => isEmail( email.trim() ) )
) {
alert(
__(
Expand All @@ -62,7 +62,7 @@ const useExpressCheckoutProductHandler = ( api ) => {
}

if ( data.hasOwnProperty( 'wc_gc_giftcard_to' ) ) {
if ( ! validator.isEmail( data.wc_gc_giftcard_to ) ) {
if ( ! isEmail( data.wc_gc_giftcard_to ) ) {
alert(
__(
'Please type only valid emails',
Expand Down

0 comments on commit 63ba2e2

Please sign in to comment.