forked from cerc-io/laconic-wallet
Add custom form validation messages (#106)
* Fix empty fields and url error msg * Use constants for error msgs
This commit is contained in:
parent
455703f91c
commit
cd03fb6e84
@ -24,23 +24,32 @@ import { COSMOS, EIP155, CHAINID_DEBOUNCE_DELAY } from '../utils/constants';
|
||||
import { getCosmosAccounts } from '../utils/accounts';
|
||||
import ETH_CHAINS from '../assets/ethereum-chains.json';
|
||||
|
||||
const EMPTY_FIELD_ERROR = 'Field cannot be empty';
|
||||
const INVALID_URL_ERROR = 'Invalid URL';
|
||||
|
||||
const ethNetworkDataSchema = z.object({
|
||||
chainId: z.string().min(1),
|
||||
networkName: z.string().min(1),
|
||||
rpcUrl: z.string().url(),
|
||||
blockExplorerUrl: z.string().url().or(z.literal('')),
|
||||
coinType: z.string().regex(/^\d+$/).min(1),
|
||||
currencySymbol: z.string().min(1),
|
||||
chainId: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
networkName: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
rpcUrl: z.string().url({ message: INVALID_URL_ERROR }),
|
||||
blockExplorerUrl: z
|
||||
.string()
|
||||
.url({ message: INVALID_URL_ERROR })
|
||||
.or(z.literal('')),
|
||||
coinType: z.string().nonempty({ message: EMPTY_FIELD_ERROR }).regex(/^\d+$/),
|
||||
currencySymbol: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
});
|
||||
|
||||
const cosmosNetworkDataSchema = z.object({
|
||||
chainId: z.string().min(1),
|
||||
networkName: z.string().min(1),
|
||||
rpcUrl: z.string().url(),
|
||||
blockExplorerUrl: z.string().url().or(z.literal('')),
|
||||
coinType: z.string().regex(/^\d+$/).min(1),
|
||||
nativeDenom: z.string().min(1),
|
||||
addressPrefix: z.string().min(1),
|
||||
chainId: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
networkName: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
rpcUrl: z.string().url({ message: INVALID_URL_ERROR }),
|
||||
blockExplorerUrl: z
|
||||
.string()
|
||||
.url({ message: INVALID_URL_ERROR })
|
||||
.or(z.literal('')),
|
||||
coinType: z.string().nonempty({ message: EMPTY_FIELD_ERROR }).regex(/^\d+$/),
|
||||
nativeDenom: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
addressPrefix: z.string().nonempty({ message: EMPTY_FIELD_ERROR }),
|
||||
});
|
||||
|
||||
const AddNetwork = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user