Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
feat: add validatio for empty spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitK-deriv committed Oct 5, 2023
1 parent ff45d77 commit d077e7a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
5 changes: 4 additions & 1 deletion crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@
"1376955476": "Swap charge",
"1377692190": "1. Go to your Deriv X dashboard.",
"1380047398": "Scan to download",
"1380676466": " is required",
"1384321002": "If you are not satisfied with the outcome, you can escalate your complaint, provided that the <0>complaints policy</0> associated with your account states that escalation is possible.",
"1384941966": "Citigroup",
"1385878133": "No money",
Expand Down Expand Up @@ -1600,6 +1601,7 @@
"1516021730": "20 - 1,000",
"1516676261": "Deposit",
"1518575473": "Uptime",
"1519951161": "Space not available",
"1521654777": "Start trading CFDs in two easy steps — click to get an account, start trading. No need to remember another login ID and password.",
"1523687535": "We don’t pay commission, but you can set your own commission rate per transaction within reasonable thresholds. When you sign up, our team will be in touch to work out the details with you.",
"1524248407": "Trade on financial markets plus our proprietary synthetics that are available 24/7.",
Expand Down Expand Up @@ -4309,8 +4311,9 @@
"-1541554430": "Next",
"-26610045": "Add an affiliate account",
"-435672026": "Wrong email",
"-1787546919": "You should enter ${min_digit}-${max_digit} characters.",
"-840841662": "Only Latin characters",
"-265889213": "Empty input not available",
"-1787546919": "You should enter ${min_digit}-${max_digit} characters.",
"-1430656728": "Password is required",
"-1049534775": "Please enter a valid postcode with Latin characters.",
"-420140433": "Company registration number is required",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const PersonalDetails = ({
onBlur={handleInput}
data-lpignore="true"
handleError={() => {
item?.value_set(null)
item?.value_set('')
item?.error_set('')
}}
/>
Expand Down
36 changes: 24 additions & 12 deletions src/pages/signup-affiliates/validations/_affilaite_validation.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from 'react'
import { localize } from 'components/localization'
/* eslint-disable */

export const affiliate_validation_regex = {
email: /[a-z0-9]+@[a-z0-9]+\.[a-z]{2,3}/,
alphabet: /^([a-zA-Z0-9-]){1,30}$/,
email: /^[a-z0-9]+@[a-z0-9]+[.][a-z]{2,}/,
latin: /[^a-zA-Za 0-9/!@"?¨'_.,-]/,
name: /[^a-zA-Za -]/,
phone: /[^0-9]/,
name: /^[^a-zA-Z-]/,
password: /^(?=.*[a-z])(?=.*\d)(?=.*[A-Z])[ -~]*$/,
address: /^[a-zA-Z 0-9/_.,-]*$/,
postal_code: /^[a-zA-Z 0-9_.-]{5,10}$/,
url: /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/,
non_empty_string: /^[^ ]+ *.*$/,
}

const validation_is_exceed_number = (input, max_digit) => {
Expand All @@ -31,16 +29,15 @@ const emailValidation = (input) => {
const userNameValidation = (input) => {
if (!input) {
return localize('_t_Username is required_t_')
} else if (
affiliate_validation_regex.latin.test(input) ||
!affiliate_validation_regex.alphabet.test(input)
) {
return localize('_t_Only Latin and Alphabet characters_t_')
} else if (affiliate_validation_regex.latin.test(input)) {
return localize('_t_Only Latin characters_t_')
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}
const nameValidation = (input, text, min_digit, max_digit) => {
if (!input) {
return text
return text + localize('_t_ is required_t_')
} else if (
!validation_is_exceed_number(input, max_digit) ||
!validation_is_lack_number(input, min_digit)
Expand All @@ -51,6 +48,8 @@ const nameValidation = (input, text, min_digit, max_digit) => {
affiliate_validation_regex.name.test(input)
) {
return localize('_t_Only Latin and Alphabet characters_t_')
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}
const companyNameValidation = (input, min_digit, max_digit) => {
Expand All @@ -63,13 +62,17 @@ const companyNameValidation = (input, min_digit, max_digit) => {
return length_error
} else if (affiliate_validation_regex.latin.test(input)) {
return localize('_t_Only Latin characters_t_')
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}
const phoneValidation = (input) => {
if (!input) {
return localize('_t_Mobile number is required_t_')
} else if (!validation_is_exceed_number(input, 11) || !validation_is_lack_number(input, 7)) {
return localize(`_t_You should enter 7-11 numbers._t_`)
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Space not available_t_')
}
}
const passwordValidation = (input, min_digit, max_digit) => {
Expand All @@ -84,8 +87,9 @@ const passwordValidation = (input, min_digit, max_digit) => {
return localize(
`_t_Password should have lower and uppercase English letters with numbers._t_`,
)
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
return null
}
const postcodeValidation = (input, min_digit, max_digit) => {
if (!input) {
Expand All @@ -97,6 +101,8 @@ const postcodeValidation = (input, min_digit, max_digit) => {
return localize(`_t_You should enter ${min_digit}-${max_digit} characters._t_`)
} else if (!affiliate_validation_regex.postal_code.test(input)) {
return localize(`_t_Please enter a valid postcode with Latin characters._t_`)
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}
const registrationNumberValidation = (input, min_digit, max_digit) => {
Expand All @@ -109,6 +115,8 @@ const registrationNumberValidation = (input, min_digit, max_digit) => {
return localize(`_t_You should enter ${min_digit}-${max_digit} characters._t_`)
} else if (!affiliate_validation_regex.postal_code.test(input)) {
return localize(`_t_Please enter a valid company registration number._t_`)
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}
const addressValidation = (input, text, min_digit, max_digit) => {
Expand All @@ -124,11 +132,15 @@ const addressValidation = (input, text, min_digit, max_digit) => {
return localize(`_t_You should enter ${min_digit}-${max_digit} characters._t_`)
} else if (!affiliate_validation_regex.address.test(input)) {
return localize('_t_Please enter a valid state_t_')
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}
const urlValidation = (input) => {
if (!affiliate_validation_regex.url.test(input)) {
return localize(`_t_Please enter a valid url_t_`)
} else if (!affiliate_validation_regex.non_empty_string.test(input)) {
return localize('_t_Empty input not available_t_')
}
}

Expand Down

0 comments on commit d077e7a

Please sign in to comment.