Closed
Description
In Typescript the optional word is used to mean that an property in the object can be undefined
.
Optional Properties
Not all properties of an interface may be required. Some exist under certain conditions or may not be there at all. These optional properties are popular when creating patterns like “option bags” where you pass an object to a function that only has a couple of properties filled in.
But the IsOptional
decorator checks if its an empty string
and not null
.
return object[propertyName] !== "" && object[propertyName] !== null;
In my opinion IsOptional
should check if it is undefined
(and maybe null
) and the current version should be renamed.
Metadata
Metadata
Assignees
Labels
No labels