Skip to content

Commit

Permalink
improve type of list data type and expose it
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskalmar committed Feb 15, 2021
1 parent e53b582 commit 6dd33f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/engine/datatype/ListDataType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ import {
} from './DataType';
import { ComplexDataType, isComplexDataType } from './ComplexDataType';

export type ListDataTypeBuildSetupType = {
description?: string;
itemType: Entity | DataType | ComplexDataType | DataTypeFunction;
minItems?: number;
maxItems?: number;
required?: boolean;
};

export type ListDataTypeSetupType = {
name: string;
description: string;
itemType: Entity | ComplexDataType | DataTypeFunction;
itemType: Entity | DataType | ComplexDataType | DataTypeFunction;
minItems?: number;
maxItems?: number;
};
Expand Down Expand Up @@ -147,9 +155,9 @@ export const isListDataType = (obj: unknown): obj is ListDataType => {
return obj instanceof ListDataType;
};

export const buildListDataType = (obj: {
itemType: Entity | DataType | ComplexDataType | DataTypeFunction;
}): DataTypeFunction => {
export const buildListDataType = (
obj: ListDataTypeBuildSetupType,
): DataTypeFunction => {
return ({ setup: { name, description } }): ListDataType =>
new ListDataType({
description,
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import {
ListDataType,
isListDataType,
buildListDataType,
ListDataTypeSetupType,
} from './engine/datatype/ListDataType';

import { Language } from './engine/models/Language';
Expand Down Expand Up @@ -224,6 +225,7 @@ export {
ListDataType,
isListDataType,
buildListDataType,
ListDataTypeSetupType,
passOrThrow,
resolveFunctionMap,
isMap,
Expand Down

0 comments on commit 6dd33f9

Please sign in to comment.