-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix snapshots validation and links array component (#6613)
* Fixed snapshots link validation * Fixed webhooks disabled button --------- Co-authored-by: Jake Naviasky <[email protected]>
- Loading branch information
Showing
5 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 15 additions & 9 deletions
24
...ealth/client/scripts/views/pages/CommunityManagement/Integrations/Snapshots/validation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import z from 'zod'; | ||
|
||
const snapshotValidationSchema = z.string().refine( | ||
(space) => { | ||
const extension = space.slice(space.length - 4); | ||
return extension === '.eth' || extension === '.xyz'; | ||
}, | ||
{ | ||
message: 'Snapshot name must be in the form of *.eth or *.xyz', | ||
}, | ||
); | ||
const snapshotNameSchema = z.string().regex(/^[a-zA-Z0-9-.]+\.((xyz)|(eth))$/, { | ||
message: 'Snapshot must be valid, and end in *.eth or *.xyz', | ||
}); | ||
const snapshotLinkSchema = z | ||
.string() | ||
.regex( | ||
/^https:\/\/(\w+\.)?snapshot\.org\/#\/[a-zA-Z0-9-.]+\.((xyz)|(eth))$/, | ||
{ | ||
message: 'Snapshot link be valid, and end in *.eth or *.xyz', | ||
}, | ||
); | ||
const snapshotValidationSchema = z.union([ | ||
snapshotNameSchema, | ||
snapshotLinkSchema, | ||
]); | ||
|
||
export { snapshotValidationSchema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters