API
Codecs
The codec factories, their shared options, and the types behind them.
Factories
| Export | Value type | Options |
|---|---|---|
stringCodec(options?) | string | trim, minLength, maxLength, pattern |
numberCodec(options?) | number | int, min, max, outOfRange |
booleanCodec(options?) | boolean | none beyond the shared ones |
enumCodec(values, options?) | values[number] | none beyond the shared ones |
dateCodec(options) | Date | format (required), min, max, outOfRange |
arrayCodec(item, options?) | item[] | separator, minItems, maxItems, unique, invalidItems |
schemaCodec(schema, options?) | the schema's output | format (URL format, JSON by default), shared ones without validate |
defineCodec(format) | your type | returns a factory that takes the shared options |
Shared options: default, validate, historyMode, omitDefault. See Built-in codecs for each one.
Types
Hover the name for its full signature.
import type { ParseResult, QueryCodec, QueryIssue } from '@chronicstone/vue-route-query'
| Type | Description |
|---|---|
QueryCodec<TValue, TState> | What a factory returns: parse, serialize, defaultValue, historyMode, omitDefault. TState is the ref type. |
ParseResult<T> | { ok: true; value; issue? } or { ok: false; issue }. |
QueryIssue | { reason: 'format' | 'option' | 'validate' | 'group'; message; rule? }. |
QueryFormat<T> | { parse, serialize }, the argument of defineCodec. |
InferCodecState<C> | The ref type a codec produces. |
AnyQueryCodec | Any codec, for your own helpers and resolve results. |