setLabels
Sets field names for the {label} parameter in the whole app — like attributes in a Laravel lang file.
Signature
ts
function setLabels(labels: Record<string, string>): voidParameters
| Parameter | Type | Description |
|---|---|---|
labels | Record<string, string> | Field path → name. Use * for array items: 'items.*.title' |
Notes
- Priority:
labelin the schema and the call'slabelsoption →setLabels→ the field name. - Calls add up: new names are added to the existing ones.
Example
ts
import { setMessages, setLabels } from 'tinyval';
setMessages({ required: '{label} is required' });
setLabels({ email: 'Email address', 'items.*.qty': 'Quantity' });
validate(Order, { items: [{}] }).errors;
// { email: 'Email address is required', 'items.0.qty': 'Quantity is required' }