UNPKG

@obosbbl/validation

Version:

A collection of validation methods for OBOS

79 lines (76 loc) 2.54 kB
type ValidatorOptions = { /** * Allow formatting characters * @default false */ allowFormatting?: boolean; }; type PostalCodeOptions = ValidatorOptions; /** * Validates that the input value is a Norwegian postal (zip) code. * @example * ``` * validatePostalCode('0000') // => true * ``` */ declare function validatePostalCode(value: string, options?: PostalCodeOptions): boolean; type PhoneNumberOptions = ValidatorOptions & { /** * Whether it should be a mobile number * @default false */ mobileOnly?: boolean; }; /** * Validates that the input value is a Norwegian phone number. * * Supports mobile only validation. * @example * ``` * validatePhoneNumber('00000000') // => true * validatePhoneNumber('90000000', { mobileOnly: true }) // => true * ``` */ declare function validatePhoneNumber(value: string, options?: PhoneNumberOptions): boolean; type OrganizationNumberOptions = ValidatorOptions; /** * Validates that the input value is a {@link https://www.brreg.no/om-oss/registrene-vare/om-enhetsregisteret/organisasjonsnummeret/ Norwegian organization number}. * @example * ``` * validateOrganizationNumber('000000000') // => true * ``` */ declare function validateOrganizationNumber(value: string, options?: OrganizationNumberOptions): boolean; /** * Validates that the input value is an OBOS membership number. * @example * ``` * validateObosMembershipNumber('0000000') // => true * ``` */ declare function validateObosMembershipNumber(value: string, options?: PostalCodeOptions): boolean; type NationalIdentityNumberOptions = ValidatorOptions; /** * Validates that the input value is a Norwegian national identity number (fødselsnummer or d-nummer). * * It validates the control digits and checks if the date of birth is valid. * * @example * ``` * validatePersonalIdentityNumber('DDMMYYXXXXX') // => true * ``` */ declare function validateNationalIdentityNumber(value: string, options?: NationalIdentityNumberOptions): boolean; type AccountNumberOptions = ValidatorOptions; /** * Validates that the input value is a Norwegian bank account number (kontonummer). * * It validates the control digit. * * @example * ``` * validateAccountNumber('XXXXXXXXXXX') // => true * ``` */ declare function validateAccountNumber(value: string, options?: AccountNumberOptions): boolean; export { validateAccountNumber, validateNationalIdentityNumber, validateObosMembershipNumber, validateOrganizationNumber, validatePhoneNumber, validatePostalCode };