phone countrycode validation in env vars

ref #18 #16
This commit is contained in:
Philipp Dormann 2020-12-06 11:21:10 +01:00
parent 99d8a0360f
commit fcfc10f7d1
4 changed files with 8 additions and 4 deletions

View File

@ -3,5 +3,6 @@ dotenvSafe.config();
export const config = {
internal_port: process.env.APP_PORT || 4010,
development: process.env.NODE_ENV === "production",
jwt_secret: process.env.JWT_SECRET || "secretjwtsecret"
jwt_secret: process.env.JWT_SECRET || "secretjwtsecret",
phone_validation_countrycode: process.env.PHONE_COUNTRYCODE || "ZZ"
}

View File

@ -1,5 +1,6 @@
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm';
import { config } from '../../config';
import { AddressNotFoundError, AddressWrongTypeError } from '../../errors/AddressErrors';
import { Address } from '../entities/Address';
import { GroupContact } from '../entities/GroupContact';
@ -40,7 +41,7 @@ export class CreateGroupContact {
* Optional
*/
@IsOptional()
@IsPhoneNumber("DE")
@IsPhoneNumber(config.phone_validation_countrycode)
phone?: string;
/**

View File

@ -8,6 +8,7 @@ import {
IsString
} from "class-validator";
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { config } from '../../config';
import { Address } from "./Address";
import { RunnerGroup } from "./RunnerGroup";
@ -62,7 +63,7 @@ export class GroupContact {
*/
@Column({ nullable: true })
@IsOptional()
@IsPhoneNumber("DE")
@IsPhoneNumber(config.phone_validation_countrycode)
phone?: string;
/**

View File

@ -8,6 +8,7 @@ import {
IsString
} from "class-validator";
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
import { config } from '../../config';
import { Address } from "./Address";
import { Donation } from "./Donation";
@ -62,7 +63,7 @@ export abstract class Participant {
*/
@Column({ nullable: true })
@IsOptional()
@IsPhoneNumber("DE")
@IsPhoneNumber(config.phone_validation_countrycode)
phone?: string;
/**