feat: implement getFieldById method

This commit is contained in:
StevanFreeborn
2023-02-02 21:37:40 -06:00
parent 8b61dfa36a
commit a1d3683603
6 changed files with 340 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
import { FieldStatus } from '../enums/FieldStatus';
import { FieldType } from '../enums/FieldType';
export class Field {
public id: number;
public appId: number;
public name: string;
public type: FieldType;
public status: FieldStatus;
public isRequired: boolean;
public isUnique: boolean;
public constructor(
id: number,
appId: number,
name: string,
type: string,
status: string,
isRequired: boolean,
isUnique: boolean
) {
if (FieldType[type] === undefined) {
throw new Error(`The type '${type}' is not a valid FieldType.`);
}
if (FieldStatus[status] === undefined) {
throw new Error(`The status '${status}' is not a valid FieldStatus.`);
}
this.id = id;
this.appId = appId;
this.name = name;
this.type = FieldType[type];
this.status = FieldStatus[status];
this.isRequired = isRequired;
this.isUnique = isUnique;
}
}