Skip to content

Commit c1f71dd

Browse files
authored
Merge pull request #353 from code0-tech/feat/#347
Adding generics to validateDataType method
2 parents 9441981 + 7b7ff44 commit c1f71dd

File tree

4 files changed

+393
-323
lines changed

4 files changed

+393
-323
lines changed

src/components/d-flow/data-type/DFlowDataType.view.ts

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ export class DataType {
146146
this._generic_keys = dataType.genericKeys
147147
}
148148

149-
/**
150-
* @todo check if EDataType is equal
151-
* @todo on deep equal do type checking and also disregard set genericKeys
152-
*/
153149
public validateDataType(dataType: DataType): boolean {
154150

151+
if (this._type != dataType.type) return false
152+
153+
const isObject = (object: object) => {
154+
return object != null && typeof object === "object";
155+
}
156+
155157
//all rules need to match
156158
const isDeepEqual = (object1: { [index: string]: any }, object2: { [index: string]: any }) => {
157159
const objKeys1 = Object.keys(object1)
@@ -169,30 +171,9 @@ export class DataType {
169171
return true
170172
}
171173

172-
const isObject = (object: object) => {
173-
return object != null && typeof object === "object";
174-
}
175-
176174
const arraysEqual = (a1: [], a2: []): boolean =>
177175
a1.length === a2.length && a1.every((o: any, idx: any) => isDeepEqual(o, a2[idx]))
178176

179-
//check input types
180-
/*
181-
if (this._inputTypes?.length !== dataType._inputTypes?.length) return false
182-
183-
const notMatchingInputTypes = this._inputTypes?.map((id, index) => {
184-
return this._service.getDataType(id)?.validateDataType(this._service.getDataType(dataType._inputTypes!![index] as string) as DataType)
185-
}).includes(false)
186-
if (notMatchingInputTypes === false) return false
187-
188-
//check return type
189-
if ((this._returnType && !dataType._returnType) || !this._returnType && dataType._returnType)
190-
return false
191-
192-
if ((this._returnType && dataType._returnType) && !(this._service.getDataType(this._returnType as string)?.validateDataType(this._service.getDataType(dataType._returnType as string) as DataType)))
193-
return false
194-
*/
195-
196177

197178
if (this.allRules && !dataType.allRules) return false
198179
if (!this.allRules && dataType.allRules) return false
@@ -223,7 +204,7 @@ export class DataType {
223204
}
224205

225206
get allRules(): DataTypeRuleObject[] {
226-
return [...(this._rules || []), ...(this._service.getDataType(this._parent as string)?.allRules || [])]
207+
return [...(this._rules || []), ...((this._parent ? this._service.getDataType(this._parent)?.allRules : []) || [])]
227208
}
228209

229210
get id(): string {

0 commit comments

Comments
 (0)