UNPKG

@obliczeniowo/elementary

Version:
89 lines (88 loc) 3.45 kB
import { AbstractControl, UntypedFormGroup, ValidationErrors } from '@angular/forms'; export declare class OblValidators { /** * Expressions used to validate, you can override them on very start of your application to apply your own specific * validation for e-mail or what so ever */ static regs: { [name: string]: RegExp; }; /** * Test if email is valid * * In case you want to override it you can just change OblValidators.regs.email to what you want * * @example * * "test@test.pl" => null * "test@test" => { 'invalid-email': true } * "test" => { 'invalid-email': true } * "test@" => { 'invalid-email': true } */ static email(control: AbstractControl): ValidationErrors | null; /** * Test Polish NIP (number of task identify) */ static nip(control: AbstractControl): ValidationErrors | null; /** * Test Polish PESEL number */ static pesel(control: AbstractControl): ValidationErrors | null; /** * Validate Polish REGON number */ static regon(control: AbstractControl): ValidationErrors | null; /** * Test if contains white spaces (space, tabulator, new line) * * @example * * "test@#$%_01234" => null * "test@#$% 01234" => { 'white-spaces': true } */ static noWhiteSpaces(control: AbstractControl): ValidationErrors | null; /** * Test if value from AbstractControl contain only any alphabetical unicode sign or number 0-9 excluding _ * this unicode version can have some problem on different types of browsers * * In case you want to override it you can just change OblValidators.regs.login to what you want * * @example * * "zazolcGesiaJazn" => null * "zażółćGęsiąJaźń" => { 'non-digit-or-alphabetical': true } * "zazolcGesiaJazn0123456789" => null * "zazolcGesiaJaznń0123456789_" => { 'non-digit-or-alphabetical': true } * "zazolcGesiaJazn0123456789$%^" => { 'non-digit-or-alphabetical': true } * "zazolc gesia jazn" => { 'white-spaces': true } */ static login(control: AbstractControl): ValidationErrors | null; /** * Test if value from AbstractControl contain only any alphabetical unicode sign or number 0-9 excluding _ * this unicode version can have some problem on different types of browsers, if it's ok for you to have * ASCII only version then please use login version * * In case you want to override it you can just change OblValidators.regs.uLogin to what you want * * @example * * "zażółćGęsiąJaźń" => null * "zażółćGęsiąJaźń0123456789" => null * "zażółćGęsiąJaźń0123456789_" => { 'non-digit-or-alphabetical': true } * "zażółćGęsiąJaźń0123456789$%^" => { 'non-digit-or-alphabetical': true } * "zażółć gęsią jaźń" => { 'white-spaces': true } */ static uLogin(control: AbstractControl): ValidationErrors | null; /** * validate if values matching */ static equalValidator(value: string): (control: AbstractControl) => { [key: string]: any; } | null; /** * validate if value from form group with name is equal to value to validated field */ static equalFormFieldValidator(form: UntypedFormGroup, name: string): (control: AbstractControl) => { [key: string]: any; } | null; }