MCPcopy Create free account
hub / github.com/dfinity/orbit / validAddress

Function validAddress

apps/wallet/src/utils/form.utils.ts:261–281  ·  view source on GitHub ↗
(blockchain: string)

Source from the content-addressed store, hash-verified

259
260export const validAddress =
261 (blockchain: string) =>
262 (value: unknown): string | boolean => {
263 const hasValue = !!value;
264 if (!hasValue) {
265 // this rule only applies if there is a value
266 return true;
267 }
268
269 if (typeof value !== 'string') {
270 return i18n.global.t('forms.rules.validAddress');
271 }
272
273 try {
274 if (detectAddressFormat(blockchain, value) !== undefined) {
275 return true;
276 }
277 return i18n.global.t('forms.rules.validAddress');
278 } catch {
279 return i18n.global.t('forms.rules.validAddress');
280 }
281 };
282
283export function compareMetadata<T extends { key: string; value: string }[]>(
284 a: T | undefined,

Callers

nothing calls this directly

Calls 1

detectAddressFormatFunction · 0.90

Tested by

no test coverage detected