Skip to content

Commit

Permalink
fix: import of boolean attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisvisser committed Nov 1, 2024
1 parent caa5ceb commit 80ed9d6
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,7 @@ export class RegistrationsInputValidator {
isValid = value == null || !isNaN(+value);
} else if (type === RegistrationAttributeTypes.text) {
isValid = typeof value === 'string';
} else if (
type === RegistrationAttributeTypes.boolean &&
typeof value === 'boolean'
) {
} else if (type === RegistrationAttributeTypes.boolean) {
isValid = this.valueIsBool(value);
} else {
message = `Type '${type}' is unknown'`;
Expand Down Expand Up @@ -990,10 +987,15 @@ export class RegistrationsInputValidator {
return `The value '${valueString}' given for the attribute '${attribute}' does not have the correct format for type '${type}'`;
}

private valueIsBool(value: string | boolean): boolean {
private valueIsBool(
value: string[] | string | number | boolean | undefined,
): boolean {
if (typeof value === 'boolean') {
return true;
}
if (typeof value !== 'string') {
return false;
}
const allowedValues = ['true', 'yes', '1', 'false', '0', 'no', null];
return allowedValues.includes(value);
}
Expand Down

0 comments on commit 80ed9d6

Please sign in to comment.