Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
90b760ec
Unverified
Commit
90b760ec
authored
Nov 25, 2024
by
tom goriunov
Committed by
GitHub
Nov 25, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add extra validation for `Token info` application form (#2408)
Fixes #2406
parent
f6307cdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
text.ts
ui/shared/forms/validators/text.ts
+13
-0
TokenInfoForm.tsx
ui/tokenInfo/TokenInfoForm.tsx
+11
-2
No files found.
ui/shared/forms/validators/text.ts
0 → 100644
View file @
90b760ec
export
const
noWhitespaceValidator
=
(
value
:
unknown
)
=>
{
if
(
typeof
value
!==
'
string
'
)
{
return
true
;
}
if
(
value
===
''
)
{
return
true
;
}
const
trimmedValue
=
value
.
replace
(
/
\s
/g
,
''
);
return
trimmedValue
!==
''
||
'
Should contain text
'
;
};
ui/tokenInfo/TokenInfoForm.tsx
View file @
90b760ec
...
...
@@ -19,6 +19,7 @@ import FormFieldAddress from 'ui/shared/forms/fields/FormFieldAddress';
import
FormFieldEmail
from
'
ui/shared/forms/fields/FormFieldEmail
'
;
import
FormFieldText
from
'
ui/shared/forms/fields/FormFieldText
'
;
import
FormFieldUrl
from
'
ui/shared/forms/fields/FormFieldUrl
'
;
import
{
noWhitespaceValidator
}
from
'
ui/shared/forms/validators/text
'
;
import
TokenInfoFieldIconUrl
from
'
./fields/TokenInfoFieldIconUrl
'
;
import
TokenInfoFieldProjectSector
from
'
./fields/TokenInfoFieldProjectSector
'
;
...
...
@@ -101,6 +102,14 @@ const TokenInfoForm = ({ address, tokenName, application, onSubmit }: Props) =>
}
},
[
formState
.
isValid
,
formState
.
submitCount
]);
const
nonWhitespaceFieldRules
=
React
.
useMemo
(()
=>
{
return
{
validate
:
{
no_whitespace
:
noWhitespaceValidator
,
},
};
},
[]);
if
(
configQuery
.
isError
)
{
return
<
DataFetchAlert
/>;
}
...
...
@@ -126,7 +135,7 @@ const TokenInfoForm = ({ address, tokenName, application, onSubmit }: Props) =>
<
FormFieldEmail
<
Fields
>
name="requester_email" isRequired placeholder="Requester email"
{
...
fieldProps
}
/
>
<
TokenInfoFormSectionHeader
>
Project info
</
TokenInfoFormSectionHeader
>
<
FormFieldText
<
Fields
>
name="project_name" placeholder="Project name"
{
...
fieldProps
}
/
>
<
FormFieldText
<
Fields
>
name="project_name" placeholder="Project name"
{
...
fieldProps
}
rules=
{
nonWhitespaceFieldRules
}
/
>
<
TokenInfoFieldProjectSector
{
...
fieldProps
}
config=
{
configQuery
.
data
.
projectSectors
}
/>
<
FormFieldEmail
<
Fields
>
name="project_email" isRequired placeholder="Official project email address"
{
...
fieldProps
}
/
>
<
FormFieldUrl
<
Fields
>
name="project_website" isRequired placeholder="Official project website"
{
...
fieldProps
}
/
>
...
...
@@ -141,7 +150,7 @@ const TokenInfoForm = ({ address, tokenName, application, onSubmit }: Props) =>
isRequired
placeholder="Project description"
maxH="160px"
rules=
{
{
maxLength
:
300
}
}
rules=
{
{
maxLength
:
300
,
...
nonWhitespaceFieldRules
}
}
asComponent="Textarea"
{
...
fieldProps
}
/
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment