Skip to content

Commit 341f896

Browse files
committed
feat: add email validation function and include email icon
1 parent 5d434da commit 341f896

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/Assets/IconV2/ic-email.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Shared/Components/Icon/Icon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { ReactComponent as ICDiscordFill } from '@IconsV2/ic-discord-fill.svg'
5656
import { ReactComponent as ICDockerhub } from '@IconsV2/ic-dockerhub.svg'
5757
import { ReactComponent as ICEcr } from '@IconsV2/ic-ecr.svg'
5858
import { ReactComponent as ICEdit } from '@IconsV2/ic-edit.svg'
59+
import { ReactComponent as ICEmail } from '@IconsV2/ic-email.svg'
5960
import { ReactComponent as ICEnterpriseFeat } from '@IconsV2/ic-enterprise-feat.svg'
6061
import { ReactComponent as ICEnterpriseTag } from '@IconsV2/ic-enterprise-tag.svg'
6162
import { ReactComponent as ICEnv } from '@IconsV2/ic-env.svg'
@@ -215,6 +216,7 @@ export const iconMap = {
215216
'ic-dockerhub': ICDockerhub,
216217
'ic-ecr': ICEcr,
217218
'ic-edit': ICEdit,
219+
'ic-email': ICEmail,
218220
'ic-enterprise-feat': ICEnterpriseFeat,
219221
'ic-enterprise-tag': ICEnterpriseTag,
220222
'ic-env': ICEnv,

src/Shared/validations.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,28 @@ export const validateYAML = (yamlString: string, isRequired?: boolean): Validati
497497
}
498498
}
499499
}
500+
501+
export const validateEmail = (email: string): ValidationResponseType => {
502+
if (!email) {
503+
return {
504+
isValid: false,
505+
message: 'Email is required',
506+
}
507+
}
508+
509+
const re =
510+
// eslint-disable-next-line no-useless-escape
511+
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
512+
const result = re.test(String(email).toLowerCase())
513+
514+
if (result) {
515+
return {
516+
isValid: true,
517+
}
518+
}
519+
520+
return {
521+
isValid: false,
522+
message: 'Please provide a valid email address',
523+
}
524+
}

0 commit comments

Comments
 (0)