Skip to main content
Checks whether a value can be safely converted to CallData without throwing an error. Useful for input validation.

Signature

Parameters

  • value - Value to validate (any type)

Returns

boolean - true if value can be converted to CallData, false otherwise

Examples

Validation Rules

Checks multiple criteria:

Use Cases

API Input Validation

Safe Constructor Pattern

Form Validation

Batch Validation

Performance

Validation is fast (basic checks only):
Validation fails early on invalid input.

Comparison with Constructor

Advantages:
  • No try-catch needed
  • Clear validation logic
  • Better performance (checks once)
Use isValid for cleaner validation logic.

Type Narrowing

TypeScript doesn’t narrow types with isValid:
For type narrowing, use is() type guard instead.

Validation Errors

Does not provide detailed error messages:
For detailed errors, use constructor in try-catch.
  • is - Type guard with narrowing
  • from - Universal constructor
  • fromHex - Parse hex string
  • fromBytes - Create from bytes