@backland/schema
Version:
TypeScript schema declaration and validation library with static type inference
21 lines (20 loc) • 1.13 kB
TypeScript
import type { ParsedPhoneNumber, PhoneNumberTypes } from '@backland/utils/lib/parsePhoneNumber';
import { FieldType, FieldTypeParser } from './FieldType';
export type { PhoneNumberTypes, ParsedPhoneNumber };
export type PhoneValidationOptions = {
regionCode?: string;
numberType?: PhoneNumberTypes;
};
export type PhoneFieldDef = PhoneValidationOptions | undefined;
export declare const E164_PHONE_REGEX: RegExp;
export declare function _backendValidatePhoneNumber(input: unknown, options?: PhoneValidationOptions): string;
export type PhoneValidator = typeof _backendValidatePhoneNumber;
export declare function setCustomPhoneValidator(validator: PhoneValidator): typeof _backendValidatePhoneNumber;
export declare function validatePhoneNumber(input: unknown, options?: PhoneValidationOptions): string;
export declare class PhoneField extends FieldType<string, 'phone', PhoneFieldDef> {
parse: FieldTypeParser<string>;
static is(input: any): input is PhoneField;
static assert(input: any): asserts input is PhoneField;
constructor(def: PhoneFieldDef);
static create: (def: PhoneFieldDef) => PhoneField;
}