Cleanup: Renamed the creation folder to the more fitting "actions"

ref #11 #13
This commit is contained in:
2020-12-05 18:45:47 +01:00
parent 5c259484ee
commit 0e924449d6
21 changed files with 32 additions and 9 deletions

View File

@@ -0,0 +1,37 @@
import { IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm';
import { GroupContactNotFoundError, GroupContactWrongTypeError } from '../../errors/GroupContactErrors';
import { GroupContact } from '../entities/GroupContact';
export abstract class CreateRunnerGroup {
/**
* The group's name.
*/
@IsNotEmpty()
@IsString()
name: string;
/**
* The group's contact.
* Optional
*/
@IsInt()
@IsOptional()
contact?: number;
/**
* Deals with the contact for groups this.
*/
public async getContact(): Promise<GroupContact> {
if (this.contact === undefined) {
return null;
}
if (!isNaN(this.contact)) {
let address = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact });
if (!address) { throw new GroupContactNotFoundError; }
return address;
}
throw new GroupContactWrongTypeError;
}
}