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

Commit

Permalink
behnaz/MARK-1263/wesite2-notmandatory (#7773)
Browse files Browse the repository at this point in the history
* chore: not show err in 1-load also null in empty validation

* chore: validation for empty return null err

* chore: remove extra empty checking from regex

* chore: validation err for website2

* chore: 1 lenght show err validation

* chore: 1 trimed lenght show err validation

* chore: remove lenght 1 from validation check

* chore: empty commit

* chore: lengh 1 err

* chore: empty commit

* chore: err msg
  • Loading branch information
behnaz-deriv authored Jun 5, 2024
1 parent 1118764 commit 9c285b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ const AccountDetails = ({
website_url_error_msg:
form_data.website_url &&
(affiliate_validation['website_url'](form_data['website_url']) ?? ''),
second_website_url_error_msg: affiliate_validation['second_website_url'](form_data['second_website_url']) ?? '',
second_website_url_error_msg:
form_data.second_website_url &&
(affiliate_validation['second_website_url'](form_data['second_website_url']) ?? ''),
password_error_msg:
form_data.password && (affiliate_validation['password'](form_data['password']) ?? ''),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ export const affiliate_validation_regex = {
name: (value: string) =>
/^(?!.*\s{2,})[\p{L}\s'.-]{2,50}$/u.test(value) &&
value.trim().length >= 2 &&
value.length <= 50,
value.trim().length <= 50,
phone: (value: string) => /^\+?\d+$/.test(value),
username: (value: string) => /^[A-Za-z0-9_]{3,20}$/.test(value),
password: (value: string) =>
/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?!.*\W)(?!.* ).{8,50}$/.test(value),
city: (value: string) =>
/^[\p{L}][\p{L}\s'.-]{0,49}$/u.test(value) &&
value.trim().length >= 2 &&
value.length <= 50,
value.trim().length <= 50,
street: (value: string) =>
/^[\p{L}\p{Nd}'.,:;()\\x{b0}@#/-][\p{L}\p{Nd}\s'.,:;()\\x{b0}@#/-]{0,68}$/u.test(value) &&
value.trim().length >= 2 &&
value.length <= 69,
value.trim().length <= 69,
postal_code: (value: string) => /^[a-zA-Z 0-9-]{2,10}$/.test(value.trim()),
company_registration_number: (value: string) => /^[a-zA-Z0-9]{2,20}$/.test(value),
company_registration_number: (value: string) => /^[a-zA-Z0-9]{2,20}$/.test(value.trim()),
url: (value: string) => /^[\w_@.\/:#&+-]*$/.test(value),
non_empty_string: (value: string) => /^\S.*$/.test(value),
}
Expand Down Expand Up @@ -136,13 +136,16 @@ const cityValidation = (input: string) => {
const urlValidation = (input: string, website_number: number ) => {
if (!input && website_number == 1 ) return localize('_t_Website url is required_t_')
if (
!affiliate_validation_regex.url(input) ||
!affiliate_validation_regex.non_empty_string(input)
(website_number == 1) &&
(!affiliate_validation_regex.url(input) ||
!affiliate_validation_regex.non_empty_string(input))
) {
return localize('_t_Please enter a valid url_t_')
} else if (input.length < 2 || input.length > 50) {
} else if ((website_number == 1) && (input.length < 2 || input.length > 50)) {
return localize('_t_You should enter 2-50 characters._t_')
}
} else if ((website_number == 2) &&
(!affiliate_validation_regex.url(input) || (input.trim().length > 50) || (input.trim().length == 1)))
return localize('_t_Please enter a valid url_t_');
}

const affiliate_validation = {
Expand Down

0 comments on commit 9c285b9

Please sign in to comment.