@ -12,8 +12,6 @@ export interface MinAgeOptions {
export function validateMinAge({ age = 18 }: MinAgeOptions = {}): ValidatorFn {
return (control: AbstractControl): MinAgeError | null => {
if (control.pristine) return null;
if (['', null, undefined].indexOf(control.value) > -1) return null;
return isValidMinAge(control.value, age) ? null : { minAge: { age } };
@ -6,8 +6,6 @@ export interface CreditCardError {
export function validateCreditCard(): ValidatorFn {
return (control: AbstractControl): CreditCardError | null => {
return isValidCreditCard(String(control.value)) ? null : { creditCard: true };
@ -14,8 +14,6 @@ export interface RangeOptions {
export function validateRange({ maximum = Infinity, minimum = 0 }: RangeOptions = {}): ValidatorFn {
return (control: AbstractControl): RangeError | null => {
const value = Number(control.value);
@ -10,9 +10,7 @@ export interface RequiredOptions {
export function validateRequired({ allowEmptyStrings }: RequiredOptions = {}): ValidatorFn {
return (control: AbstractControl): RequiredError | null => {
return control.pristine || isValidRequired(control.value, allowEmptyStrings)
? null
: { required: true };
return isValidRequired(control.value, allowEmptyStrings) ? null : { required: true };
};
}
@ -19,8 +19,6 @@ export function validateStringLength({
minimumLength = 0,
}: StringLengthOptions = {}): ValidatorFn {
return (control: AbstractControl): StringLengthError | null => {
const value = String(control.value);
@ -6,8 +6,6 @@ export interface UrlError {
export function validateUrl(): ValidatorFn {
return (control: AbstractControl): UrlError | null => {
return isValidUrl(control.value) ? null : { url: true };