Skip to main content

isValidAssetName

Tool to verify the validity of an asset name.

Submit feedback
github
import { isValidAssetName } from '@uhg-abyss/web/tools/isValidAssetName';

The isValidAssetName tool is used to check if a given string is a valid asset name for a given component. Using this tool is only necessary when using TypeScript, as it provides type safety for asset names. The function has the following signature:

type Component =
| 'IconBrand'
| 'IconMaterial'
| 'IconSymbol'
| 'IllustratedIconBrand'
| 'IllustrationBrand';
const isValidAssetName: (name: string, component: Component) => boolean;

Usage

isValidAssetName is primarily used as a way to contitionally render components if the asset name is valid. Try providing a value of home or star below to see this in action!

Table of Contents