Skip to content

Otp

Interface

export type IOtpTypeValue = string;
 
export interface IOtpField extends CommonField {
    type: 'otp';
    options?: {
        length?: number;
        pattern?: RegExp;
        separator?: boolean;
        label?: string;
    };
    private?: () => Promise<IOtpTypeValue>;
    render?: (v: IOtpTypeValue) => JSX.Element;
    validation?: Validation<IOtpTypeValue>;
}

Example

Basic OTP Field

{
  type: 'otp',
  name: 'YOUR_PATH',
}

Complex OTP Field

{
  type: 'otp',
  name: 'YOUR_PATH',
  options: {
    length: 12,
    pattern: /^\d+$/,
    separator: true,
    label: 'OTP Code'
  }
}