Skip to main content

Try it Live

Run Address examples in the interactive playground
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
View the complete executable example at playground/src/examples/primitives/address/is-address.ts.

C FFI

primitives_address_is_valid(const PrimitivesAddress* addr): bool

Validate address pointer is non-null (size already enforced by struct). Parameters:
  • addr: const PrimitivesAddress* - Address pointer to check
Returns: bool - true if pointer is non-null Example:
Note: C struct definition enforces 20-byte size. Runtime check only validates pointer.

TypeScript Type Predicates

Type guards use TypeScript’s is operator to narrow types:
Benefits:
  • Type safety without type assertions
  • Catches errors at compile time
  • No runtime overhead (inline check)
  • Works with TypeScript’s control flow analysis

Type Narrowing

Type guards enable safe handling of unknown values:

Basic Narrowing

Union Type Narrowing

Array Filtering

Defensive Programming

Type guards enable validation at system boundaries:

API Input Validation

User Input Sanitization

External Data Validation

Implementation Details

Check logic:
Two conditions:
  1. instanceof Uint8Array - Must be Uint8Array (not regular Array)
  2. length === 20 - Exactly 20 bytes (not 19, not 21)
What it accepts:
What it rejects:

Use Cases

Function Overloading

Safe Deserialization

Collection Validation

Comparison with Other Validators

vs Address.isValid(hex)

isValid validates hex string format:
is validates AddressType type:

vs Address.isValidChecksum(hex)

isValidChecksum validates EIP-55 checksumming:
is doesn’t validate checksum:
Summary:
  • Address.is(value) - Runtime type guard for AddressType
  • Address.isValid(hex) - Validates hex string format
  • Address.isValidChecksum(hex) - Validates EIP-55 checksum

See Also