Added the address class

ref #11
This commit is contained in:
Nicolai Ort 2020-12-01 19:03:41 +01:00
parent 8b2d6840a8
commit 2bd0cbadbe
1 changed files with 73 additions and 0 deletions

73
src/models/Address.ts Normal file
View File

@ -0,0 +1,73 @@
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
import {
IsInt,
IsNotEmpty,
IsOptional,
IsPostalCode,
IsString,
} from "class-validator";
/**
* Defines a address (to be used for contact information).
*/
@Entity()
export class Address {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The address's description.
*/
@Column()
@IsString()
@IsOptional()
description?: string;
/**
* The address's first line.
* Containing the street and house number.
*/
@Column()
@IsString()
@IsNotEmpty()
address1: string;
/**
* The address's second line.
* Containing optional information.
*/
@Column()
@IsString()
@IsOptional()
address2?: string;
/**
* The address's postal code.
*/
@Column()
@IsString()
@IsNotEmpty()
@IsPostalCode("DE")
postalcode: string;
/**
* The address's city.
*/
@Column()
@IsString()
@IsNotEmpty()
city: string;
/**
* The address's country.
*/
@Column()
@IsString()
@IsNotEmpty()
country: string;
}