Implemented postal code validation for the validaton function

ref #105
This commit is contained in:
Nicolai Ort 2021-01-16 18:59:06 +01:00
parent 4824547dde
commit f245840cde
1 changed files with 2 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import {
IsString
} from "class-validator";
import { Column } from "typeorm";
import ValidatorJS from 'validator';
import { config } from '../../config';
/**
@ -62,6 +63,7 @@ export class Address {
public static isValidAddress(address: Address): Boolean {
if (address == null) { return false; }
if (address.address1 == null || address.city == null || address.country == null || address.postalcode == null) { return false; }
if (ValidatorJS.isPostalCode(address.postalcode, config.postalcode_validation_countrycode) == false) { return false; }
return true;
}
}