You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A version of @IsOptional that would allow null but not undefined would be a great add for a lot of use cases. Additionally, a version that allowed undefined but not null would come in handy for certain operations as well - I would think this is what @IsOptional should do, but the docs state that it allows null AND undefined, which I don't think is particularly intuitive.
The text was updated successfully, but these errors were encountered:
You can create "optionally null" and "optionally undefined" decorators by decorating the @ValidateIf decorator
/** * Skips validation if the target is null */functionIsNullable(options?: ValidationOptions): PropertyDecorator{returnfunctionIsNullableDecorator(prototype: Object,propertyKey: string|symbol){ValidateIf((obj)=>(obj)[propertyKey]!==null,options)(prototype,propertyKey);};}/** * Skips validation if the target is undefined */functionIsUndefinable(options?: ValidationOptions): PropertyDecorator{returnfunctionIsUndefinedDecorator(prototype: Object,propertyKey: string|symbol){ValidateIf((obj)=>(obj)[propertyKey]!==undefined,options)(prototype,propertyKey);};}
A version of
@IsOptional
that would allow null but not undefined would be a great add for a lot of use cases. Additionally, a version that allowed undefined but not null would come in handy for certain operations as well - I would think this is what@IsOptional
should do, but the docs state that it allows null AND undefined, which I don't think is particularly intuitive.The text was updated successfully, but these errors were encountered: