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
I was following another tutorial on the blog and found yours, which is the newest one, and decided to follow along.
I want to raise a point and see what you think about it. The CreateArticleDto has the IsOptional() decorator in the description property, which means it validates if the field is present or not. Then you have the IsString() decorator to validate if the property is a string. But at any moment you're validating if the string is "valid" or not.
Generally, I (personally) like to also add an IsNotEmpty() decorator, to ignore "" (empty strings) values as well. This way you enforce that description is optional, but if present, it cannot be empty.
Not a really big problem, but it can avoid, in a big db table, for example, the need to write SELECT * FROM ARTICLES WHERE description IS NOT NULL AND description <> ''.
Any thoughts? 😄
The text was updated successfully, but these errors were encountered:
Hi @TasinIshmam!
I was following another tutorial on the blog and found yours, which is the newest one, and decided to follow along.
I want to raise a point and see what you think about it. The
CreateArticleDto
has theIsOptional()
decorator in thedescription
property, which means it validates if the field is present or not. Then you have theIsString()
decorator to validate if the property is a string. But at any moment you're validating if the string is "valid" or not.Generally, I (personally) like to also add an
IsNotEmpty()
decorator, to ignore""
(empty strings) values as well. This way you enforce thatdescription
is optional, but if present, it cannot be empty.Not a really big problem, but it can avoid, in a big db table, for example, the need to write
SELECT * FROM ARTICLES WHERE description IS NOT NULL AND description <> ''
.Any thoughts? 😄
The text was updated successfully, but these errors were encountered: