parent
58ae9b589a
commit
2a465f88c5
@ -1,69 +0,0 @@
|
|||||||
import { IsNotEmpty, IsOptional, IsPostalCode, IsString } from 'class-validator';
|
|
||||||
import { config } from '../../../config';
|
|
||||||
import { Address } from '../../entities/Address';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This classed is used to create a new Address entity from a json body (post request).
|
|
||||||
*/
|
|
||||||
export class CreateAddress {
|
|
||||||
/**
|
|
||||||
* The newaddress's description.
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
@IsOptional()
|
|
||||||
description?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new address's first line.
|
|
||||||
* Containing the street and house number.
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
address1: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new address's second line.
|
|
||||||
* Containing optional information.
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
@IsOptional()
|
|
||||||
address2?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new address's postal code.
|
|
||||||
* This will get checked against the postal code syntax for the configured country.
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsPostalCode(config.postalcode_validation_countrycode)
|
|
||||||
postalcode: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new address's city.
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
city: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new address's country.
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
country: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new Address entity from this.
|
|
||||||
*/
|
|
||||||
public async toEntity(): Promise<Address> {
|
|
||||||
let newAddress: Address = new Address();
|
|
||||||
|
|
||||||
newAddress.address1 = this.address1;
|
|
||||||
newAddress.address2 = this.address2;
|
|
||||||
newAddress.postalcode = this.postalcode;
|
|
||||||
newAddress.city = this.city;
|
|
||||||
newAddress.country = this.country;
|
|
||||||
|
|
||||||
return newAddress;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,7 @@ import { Column } from "typeorm";
|
|||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the Address entity.
|
* Defines the Address class.
|
||||||
* Implemented this way to prevent any formatting differences.
|
* Implemented this way to prevent any formatting differences.
|
||||||
*/
|
*/
|
||||||
export class Address {
|
export class Address {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user