mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
1 line
22 KiB
JSON
1 line
22 KiB
JSON
|
|
{"ast":null,"code":"import { FieldType } from '../../sql/query/interface.js';\nimport { field } from './field.js';\nexport class AutoField extends field {\n constructor(data) {\n super();\n this.fieldName = 'AutoField';\n this.unique = true;\n this.autoIncrement = true;\n this.type = FieldType.BIGINT;\n this.blank = true;\n Object.assign(this, data);\n }\n valid(value) {\n if (!(typeof value == 'bigint' || typeof value == 'number')) {\n return false;\n } else if (!((this === null || this === void 0 ? void 0 : this.blank) == undefined && this.isNull(value) == false)) {\n return false;\n }\n return false;\n }\n}\nexport class BigIntegerField extends field {\n constructor(data) {\n super();\n this.fieldName = 'BigIntegerField';\n this.type = FieldType.BIGINT;\n Object.assign(this, data);\n }\n valid(value) {\n if (!(typeof value == 'bigint' || typeof value == 'number')) {\n if ((this === null || this === void 0 ? void 0 : this.blank) != true) {\n return false;\n } else if (!(value === null || value === undefined)) {\n return false;\n }\n } else if (!this.rules(this, value)) {\n return false;\n }\n return true;\n }\n}\nexport class BooleanField extends field {\n constructor(data) {\n super();\n this.fieldName = 'BooleanField';\n Object.assign(this, data);\n }\n valid(value) {\n if (typeof value != 'boolean') {\n return false;\n }\n return true;\n }\n}\nexport class CharField extends field {\n constructor(data) {\n super();\n this.fieldName = 'CharField';\n this.type = FieldType.DATE;\n Object.assign(this, data);\n }\n valid(value) {\n if (!(typeof value == 'string')) {\n if ((this === null || this === void 0 ? void 0 : this.blank) != true) {\n return false;\n } else if (!(value === null || value === undefined)) {\n return false;\n }\n } else if (!this.rules(this, value)) {\n return false;\n }\n return true;\n }\n}\nexport class DateField extends field {\n constructor(data) {\n super();\n this.fieldName = 'DateField';\n this.type = FieldType.DATE;\n Object.assign(this, data);\n }\n valid(value) {\n if (!(typeof value == 'string')) {\n if ((this === null || this === void 0 ? void 0 : this.blank) != true) {\n return false;\n }\n } else if (!((this === null || this === void 0 ? void 0 : this.blank) == undefined && this.isNull(value) == false)) {\n return true;\n }\n return false;\n }\n}\nexport class DateTimeField extends field {\n constructor(data) {\n super();\n this.fieldName = 'DateTimeField';\n this.type = FieldType.DATE;\n Object.assign(this, data);\n }\n valid(value) {\n if (!(typeof value == 'string')) {\n if ((this === null || this === void 0 ? void 0 : this.blank) != true) {\n return false;\n }\n } else if (!((this === null || this === void 0 ? void 0 : this.blank) == undefined && this.isNull(value) == false)) {\n return false;\n }\n return true;\n }\n}\nexport class indexedDBArrayField extends field {\n constructor(data) {\n super();\n this.fieldName = 'indexedDBArrayField';\n this.type = FieldType.ARRAY;\n Object.assign(this, data);\n }\n get field() {\n return this._field;\n }\n set field(value) {\n this._field = value;\n }\n valid(value) {\n if (!Array.isArray(value)) {\n if ((this === null || this === void 0 ? void 0 : this.blank) != true) {\n return false;\n }\n } else if (this.isNull(value) == true) {\n if ((this === null || this === void 0 ? void 0 : this.blank) != true) {\n return false;\n }\n } else if (this.size) {\n if (value.length != this.size) {\n return false;\n }\n }\n if (this.field) {\n for (const e of value) {\n if (!this.field.valid(e)) {\n return false;\n }\n }\n }\n return true;\n }\n}\nexport class indexedDBJsonField extends field {\n constructor(data) {\n super();\n
|