Skip to content

Commit

Permalink
Fixed #20
Browse files Browse the repository at this point in the history
Kubevious removes required fields containing empty strings #20
  • Loading branch information
rubenhak committed Jun 6, 2024
1 parent fb8ab7d commit 95ff86e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/validation/k8s-manifest-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,19 @@ export class K8sManifestValidator
const propNode = (node as any)[propName];
if (_.isString(propNode) && (propNode.length === 0))
{
if (_.isNullOrUndefined(propSchema.default))
{
delete (node as any)[propName];
}
else
if (!_.isNullOrUndefined(propSchema.default))
{
(node as any)[propName] = propSchema.default;

}

// Before we used to delete the node. This behavior causes
// a false possitive when an empty required string fails validation.
// https://github.com/kubevious/cli/issues/20
// In future should try to set the value of undefined values as default value
// of the schema. That would also help with guard functionality with validation
// that depends on default values.
// Old Code: delete (node as any)[propName];
}
}
}
Expand Down

0 comments on commit 95ff86e

Please sign in to comment.