Skip to content

Commit

Permalink
An even better approach to deal with unknown datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofVDB1 committed Nov 21, 2024
1 parent a44b473 commit 52b2b86
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/oslo-converter-uml-ea/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import type { EaObject, EaTag } from '@oslo-flanders/ea-uml-extractor';
import { TagNames } from '../enums/TagNames';
import type { UriRegistry } from '../UriRegistry';

function stringToBoolean(value: string): boolean {
return value?.toLowerCase() === 'true';
function toBoolean(value: any): boolean {
if (typeof value === 'boolean') {
return value;
}
if (typeof value === 'string') {
return value.toLowerCase() === 'true';
}
return false;
}

export function ignore(object: EaObject): boolean {
const ignoreObject = getTagValue(object, TagNames.Ignore, false);
return stringToBoolean(ignoreObject);
return toBoolean(ignoreObject);
}

export function getTagValue(
Expand Down

0 comments on commit 52b2b86

Please sign in to comment.