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.
From the Typescript hand book
But the IsOptional decorator checks if its an empty string and not null.
return object[propertyName] !== "" && object[propertyName] !== null;
Source
In my opinion IsOptional should check if it is undefined (and maybe null) and the current version should be renamed.
In Typescript the optional word is used to mean that an property in the object can be
undefined.From the Typescript hand book
But the
IsOptionaldecorator checks if its an emptystringand notnull.Source
In my opinion
IsOptionalshould check if it isundefined(and maybenull) and the current version should be renamed.