feat: begin working on implementing record methods
This commit is contained in:
+8
-18
@@ -1,5 +1,5 @@
|
||||
import { FieldStatus } from '../enums/FieldStatus';
|
||||
import { FieldType } from '../enums/FieldType';
|
||||
import { type FieldStatus } from '../enums/FieldStatus';
|
||||
import { type FieldType } from '../enums/FieldType';
|
||||
|
||||
/**
|
||||
* @class Field - Represents a Field.
|
||||
@@ -45,36 +45,26 @@ export class Field {
|
||||
* @param {number} id - The id of the Field.
|
||||
* @param {number} appId - The id of the App that the Field belongs to.
|
||||
* @param {string} name - The name of the Field.
|
||||
* @param {string} type - The type of the Field.
|
||||
* @param {string} status - The status of the Field.
|
||||
* @param {FieldType} type - The type of the Field.
|
||||
* @param {FieldStatus} status - The status of the Field.
|
||||
* @param {boolean} isRequired - Indicates whether or not the Field is required.
|
||||
* @param {boolean} isUnique - Indicates whether or not the Field is required to be unique.
|
||||
* @returns {Field} - A new Field.
|
||||
* @throws {Error} - Throws an error if the type is not valid.
|
||||
* @throws {Error} - Throws an error if the status is not valid.
|
||||
*/
|
||||
public constructor(
|
||||
id: number,
|
||||
appId: number,
|
||||
name: string,
|
||||
type: string,
|
||||
status: string,
|
||||
type: FieldType,
|
||||
status: FieldStatus,
|
||||
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.type = type;
|
||||
this.status = status;
|
||||
this.isRequired = isRequired;
|
||||
this.isUnique = isUnique;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user