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
Is your feature request related to a problem? Please describe.
When I call the isValid function on my entity instance, it returns true or false, indicating whether or not my entity is valid.
Additionally, this function includes in my entity an errors key containing the errors that were detected in the validation, according to the rules defined in the entity.
However, even when there is no error, it still creates the errors key in the entity, containing an empty object.
This can lead to problems, for example if I pass the already validated entity to another usecase, or if I pass it to some function to insert into the database, which will insert the errors key containing an empty object.
Describe the solution you'd like
I believe we can make a conditional to only insert the errors key if there really is a validation error.
In the baseEntity.js file in the line that follows:
Describe alternatives you've considered
I have not considered alternatives to this feature.
Additional context
I noticed on two points:
By adapting my project that uses herbs2mongo to save nested entities in the database.
When using a usecase that passes the request it received (entity) to another usecase.
As a temporary fix, after verifying that the entity is valid, I deleted the errors field before calling the other usecase.
deleteclient.errors;
And in the database part, I changed my DataMapper instance to delete keys that I might configure when calling my deletekeys function, as already mentioned in this issue: herbsjs/herbs2mongo#35
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When I call the isValid function on my entity instance, it returns true or false, indicating whether or not my entity is valid.
Additionally, this function includes in my entity an errors key containing the errors that were detected in the validation, according to the rules defined in the entity.
However, even when there is no error, it still creates the errors key in the entity, containing an empty object.
This can lead to problems, for example if I pass the already validated entity to another usecase, or if I pass it to some function to insert into the database, which will insert the errors key containing an empty object.
Describe the solution you'd like
I believe we can make a conditional to only insert the errors key if there really is a validation error.
In the baseEntity.js file in the line that follows:
gotu/src/baseEntity.js
Line 50 in ae6be8e
Describe alternatives you've considered
I have not considered alternatives to this feature.
Additional context
I noticed on two points:
As a temporary fix, after verifying that the entity is valid, I deleted the errors field before calling the other usecase.
And in the database part, I changed my DataMapper instance to delete keys that I might configure when calling my deletekeys function, as already mentioned in this issue: herbsjs/herbs2mongo#35
The text was updated successfully, but these errors were encountered: