args
Creates a function arguments transformation action.
const Action = v.args<TInput, TSchema>(schema);
Generics
TInputextends (...args: any[]) => unknownTSchemaextends LooseTupleSchema<TupleItems, ErrorMessage<LooseTupleIssue> | undefined> | StrictTupleSchema<TupleItems, ErrorMessage<StrictTupleIssue> | undefined> | TupleSchema<TupleItems, ErrorMessage<TupleIssue> | undefined> | TupleWithRestSchema<TupleItems, BaseSchema<unknown, unknown, BaseIssue<unknown>>, ErrorMessage<TupleWithRestIssue> | undefined>
Parameters
schemaTSchema
Explanation
With args you can force the arguments of a function to match the given schema.
Returns
ActionArgsAction<TInput, TSchema>
Examples
The following examples show how args can be used.
Function schema
Schema of a function that transforms a string to a number.
const FunctionSchema = v.pipe(
v.function(),
v.args(v.tuple([v.pipe(v.string(), v.decimal())])),
v.returns(v.number())
);
Related
The following APIs can be combined with args.
Schemas
any, custom, looseTuple, function, strictTuple, tuple, tupleWithRest
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/args/