Try it Live
Run Address examples in the interactive playground
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
bool - true if pointer is non-null
Example:
TypeScript Type Predicates
Type guards use TypeScript’sis operator to narrow types:
- 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:instanceof Uint8Array- Must be Uint8Array (not regular Array)length === 20- Exactly 20 bytes (not 19, not 21)
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:
Address.is(value)- Runtime type guard for AddressTypeAddress.isValid(hex)- Validates hex string formatAddress.isValidChecksum(hex)- Validates EIP-55 checksum
See Also
- from - Universal constructor
- isValid - Validate hex string format
- isValidChecksum - Validate EIP-55 checksum
- equals - Compare two addresses
- AddressType - Type definition

