Skip to content

@jsvision/ui / picture

Function: picture()

picture(mask, autoFill?): Validator

Defined in: ui/src/controls/validators/picture.ts:406

Create a formatted-mask validator. Auto-fill is on by default, so fixed literals (dashes, parentheses) are inserted as the user types. A malformed mask (empty, ending in ;, unbalanced brackets, or an unreasonable *N repeat) makes both gates reject and sets error — it never throws and never hangs.

Parameters

mask

string

The mask template — see the mask-syntax list above (e.g. '(###) ###-####').

autoFill?

boolean = true

Whether to auto-insert trailing literals and apply case transforms. Default true.

Returns

Validator

A Validator you can pass to an Input.

Example

ts
import { signal } from '@jsvision/ui';
import { Input, picture } from '@jsvision/ui';

const phone = signal('');
// Typing "5551234567" fills the punctuation automatically → "(555) 123-4567".
const input = new Input({ value: phone, validator: picture('(###) ###-####') });