Merge branch 'dev' into feature/40-pw_reset
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
Nicolai Ort 2020-12-22 16:05:27 +01:00
commit 853876a09c
6 changed files with 35 additions and 8 deletions

View File

@ -92,7 +92,7 @@ steps:
tags:
- $DRONE_TAG
registry: registry.odit.services
- name: trigger lib build
- name: trigger js lib build
depends_on: [clone]
image: plugins/downstream
settings:
@ -101,7 +101,19 @@ steps:
from_secret: BOT_DRONE_KEY
fork: false
repositories:
- lfk/lib
- lfk/lfk-client-js
params:
- SOURCE_TAG: $DRONE_TAG
- name: trigger node lib build
depends_on: [clone]
image: plugins/downstream
settings:
server: https://ci.odit.services/
token:
from_secret: BOT_DRONE_KEY
fork: false
repositories:
- lfk/lfk-client-node
params:
- SOURCE_TAG: $DRONE_TAG
trigger:

View File

@ -5,4 +5,5 @@ DB_PORT=unused
DB_USER=unused
DB_PASSWORD=bla
DB_NAME=./test.sqlite
NODE_ENV=dev
NODE_ENV=dev
POSTALCODE_COUNTRYCODE=null

View File

@ -5,4 +5,5 @@ DB_PORT=bla
DB_USER=bla
DB_PASSWORD=bla
DB_NAME=bla
NODE_ENV=production
NODE_ENV=production
POSTALCODE_COUNTRYCODE=null

View File

@ -1,10 +1,13 @@
import { config as configDotenv } from 'dotenv';
import ValidatorJS from 'validator';
configDotenv();
export const config = {
internal_port: parseInt(process.env.APP_PORT) || 4010,
development: process.env.NODE_ENV === "production",
jwt_secret: process.env.JWT_SECRET || "secretjwtsecret",
phone_validation_countrycode: process.env.PHONE_COUNTRYCODE || "ZZ"
phone_validation_countrycode: process.env.PHONE_COUNTRYCODE || "ZZ",
postalcode_validation_countrycode: getPostalCodeLocale()
}
let errors = 0
if (typeof config.internal_port !== "number") {
@ -19,4 +22,13 @@ if (config.phone_validation_countrycode.length !== 2) {
if (typeof config.development !== "boolean") {
errors++
}
function getPostalCodeLocale(): any {
try {
const stringArray: String[] = ValidatorJS.isPostalCodeLocales;
let index = stringArray.indexOf(process.env.POSTALCODE_COUNTRYCODE);
return ValidatorJS.isPostalCodeLocales[index];
} catch (error) {
return null;
}
}
export let e = errors

View File

@ -1,4 +1,5 @@
import { IsNotEmpty, IsOptional, IsPostalCode, IsString } from 'class-validator';
import { config } from '../../config';
import { Address } from '../entities/Address';
/**
@ -35,7 +36,7 @@ export class CreateAddress {
*/
@IsString()
@IsNotEmpty()
@IsPostalCode("DE")
@IsPostalCode(config.postalcode_validation_countrycode)
postalcode: string;
/**

View File

@ -6,6 +6,7 @@ import {
IsString
} from "class-validator";
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { config } from '../../config';
import { Participant } from "./Participant";
import { RunnerOrganisation } from "./RunnerOrganisation";
@ -52,12 +53,11 @@ export class Address {
/**
* The address's postal code.
* This will get checked against the postal code syntax for the configured country.
* TODO: Implement the config option.
*/
@Column()
@IsString()
@IsNotEmpty()
@IsPostalCode("DE")
@IsPostalCode(config.postalcode_validation_countrycode)
postalcode: string;
/**