readonly
Creates a readonly transformation action.
const Action = v.readonly<TInput>();
Generics
TInputextends any
Returns
ActionReadonlyAction<TInput>
Examples
The following examples show how readonly can be used.
Readonly array
Schema for a readonly array of numbers.
const ArraySchema = v.pipe(v.array(v.number()), v.readonly());
Readonly entry
Object schema with an entry marked as readonly.
const ObjectSchema = v.object({
name: v.string(),
username: v.pipe(v.string(), v.readonly()),
age: v.number(),
});
Related
The following APIs can be combined with readonly.
Schemas
any, array, bigint, blob, boolean, custom, date, enum, exactOptional, file, function, instance, intersect, lazy, literal, looseObject, looseTuple, map, nan, never, nonNullable, nonNullish, nonOptional, null, nullable, nullish, number, object, objectWithRest, optional, picklist, promise, record, set, strictObject, strictTuple, string, symbol, tuple, tupleWithRest, undefined, undefinedable, union, unknown, variant, void
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/readonly/