Expand description
§domainstack-wasm
WASM browser validation for domainstack. Run the same validation logic in both browser and server.
§Quick Start
import { createValidator } from '@domainstack/wasm';
const validator = await createValidator();
const result = validator.validate('Booking', {
guest_email: 'invalid',
rooms: 15
});
if (!result.ok) {
result.errors?.forEach(e => console.log(e.path, e.message));
}§Architecture
This crate provides a thin WASM layer over domainstack validation. Types are registered at compile time, and validation is dispatched by type name at runtime.
Structs§
- System
Error - System-level error (not a validation failure).
- Type
Registry - Registry of type validators.
- Validation
Error - Represents a collection of validation violations.
- Validation
Result - Result of a validation operation.
- Validator
- Validator instance for TypeScript ergonomics.
- Wasm
Violation - A validation violation, serializable for WASM.
Enums§
- Dispatch
Error - Internal error type for dispatch operations
Traits§
- Deserialize
Owned - A data structure that can be deserialized without borrowing any data from the deserializer.
- Validate
Functions§
- create_
validator - Create a validator instance.
- get_
registered_ types - Get list of registered type names.
- has_
type - Check if a type is registered.
- init
- Initialize panic hook for better error messages in browser console. Call this once at application startup.
- is_
type_ registered - Check if a type is registered
- register_
type - Register a type for WASM validation.
- registered_
types - Get list of all registered type names
- validate
- Validate JSON data against a registered type.
- validate_
object - Validate a JavaScript object against a registered type.
Type Aliases§
- Validate
Fn - Function signature for type validators