PropType
Supported property types for schema validation.PropDefinition
Defines the schema for a single property.PropType
required
The expected type of the property
boolean
Whether the property is optional. Default:
falseany
Default value if property is not provided
number
Minimum value for number types
number
Maximum value for number types
number
Minimum number of items for array and typed array types
number
Maximum number of items for array and typed array types
number
Minimum string length for string types
number
Maximum string length for string types
(string | number)[]
Allowed values for the property
string
Human-readable label for UI rendering
string
Description of the property
number
Step increment for number inputs
string
Format hint for specialized inputs
string
Regular expression pattern for string validation
string[]
Accepted file extensions for asset types
string
Group name for organizing properties in UI
PropDefinition
Schema for array items (when type is ‘array’)
HeliosSchema
Nested schema for object properties (when type is ‘object’)
HeliosSchema
A schema is a record mapping property names to their definitions.validateSchema
Validates that a schema definition is well-formed.HeliosSchema | undefined
required
Schema to validate
string
Parent key for nested validation (used internally for error messages)
Example
Errors
ThrowsHeliosError with code INVALID_SCHEMA if:
- Pattern is defined on non-string types
- Pattern regex is invalid
- Accept is defined on incompatible types
- minItems/maxItems is negative or inconsistent
- minLength/maxLength is negative or inconsistent
- Default value doesn’t match the schema constraints
validateProps
Validates component props against a schema.T
required
Props object to validate
HeliosSchema
Schema to validate against. If not provided, props are returned unchanged.
T
Validated props object with defaults applied and extra props preserved
Example
Behavior
- Required props: Props without
optional: truemust be provided or have a default - Defaults: Applied when prop is undefined
- Extra props: Props not in schema are preserved in the output
- Nested validation: Objects and arrays are validated recursively
- Type coercion: No automatic coercion; types must match exactly
Errors
ThrowsHeliosError with code INVALID_INPUT_PROPS if:
- Required prop is missing and has no default
- Prop type doesn’t match schema
- Number is outside minimum/maximum range
- String length is outside minLength/maxLength range
- Array length is outside minItems/maxItems range
- String doesn’t match pattern
- Value is not in enum
- Color string is invalid
- File extension doesn’t match accept list