Phone
Interface
export type IPhoneTypeValue = string;
export interface IPhoneField extends CommonField {
type: 'phone';
options?: {
placeholder?: string;
defaultCode?: string;
};
private?: () => Promise<IPhoneTypeValue>;
render?: (v: IPhoneTypeValue) => JSX.Element;
validation?: Validation<IPhoneTypeValue>;
}Example
Basic Example
{
type: 'phone',
name: 'YOUR_PATH',
validation: z.string()
}With Options
{
type: 'phone',
name: 'YOUR_PATH',
options: {
placeholder: 'Enter your phone number',
defaultCode: '+39'
},
validation: z.string().refine(
(val) => {
const match = val.match(/^(\+\d+)\s(\d{7,9})$/)
return !!match
},
{
message:
'Invalid phone number format. Must be: +prefix 7-9 digits'
}
)
}