(blockchain: string)
| 259 | |
| 260 | export 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 | |
| 283 | export function compareMetadata<T extends { key: string; value: string }[]>( |
| 284 | a: T | undefined, |
nothing calls this directly
no test coverage detected