Skip to content

Commit

Permalink
validate transaction id
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Jan 25, 2024
1 parent aee2e5f commit 1bbd462
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/validators/segmentAndMetadataValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GIVETH_IO_EVENTS, NETWORK_IDS } from '../utils';
// does not care about calculating values, only validating fields
const filterDateRegex = new RegExp('^[0-9]{8} [0-9]{2}:[0-9]{2}:[0-9]{2}$');
const ethereumWalletAddressRegex = /^0x[a-fA-F0-9]{40}$/;
const solanaTxRegex = /^[A-Za-z0-9]{86,88}$/;
const solanaWalletAddressRegex = /^[A-Za-z0-9]{43,44}$/;
const txHashRegex = /^0x[a-fA-F0-9]{64}$/;
const tokenSymbolRegex = /^[a-zA-Z0-9]{3,10}$/;
Expand Down Expand Up @@ -66,6 +67,10 @@ const donationTrackerSchema = Joi.object({
projectOwnerId: Joi.string().allow(null, ''),
slug: Joi.string().allow(null, ''),
amount: Joi.number()?.greater(0).required(),
transactionId: Joi.alternatives().try(
Joi.string().required().pattern(txHashRegex, 'EVM transaction IDs'),
Joi.string().required().pattern(solanaTxRegex, 'Solana Transaction ID'),
),
transactionNetworkId: Joi.number().required(),
currency: Joi.string().required(),
createdAt: Joi.string(),
Expand Down

0 comments on commit 1bbd462

Please sign in to comment.