Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable Request #11

Open
endersoncosta opened this issue May 18, 2020 · 12 comments
Open

Nullable Request #11

endersoncosta opened this issue May 18, 2020 · 12 comments
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed severity-nice-to-have Item is nice to have

Comments

@endersoncosta
Copy link
Contributor

Maybe we can change the schema validation to add a option in request structure, to inform that the value can be null or undefined and our steps will treat this...

like this:
request: { id: !Number }

or like this:
request: { id: Number || undefined }

@endersoncosta
Copy link
Contributor Author

Maybe using SUMA to validate these values...

@dalssoft
Copy link
Member

By default Suma will not validate null:
https://github.com/herbsjs/suma#null-values

When there is a need for non-nullable, use allowNull: false or presence: true
https://github.com/herbsjs/suma#presence-vs-allownull

How do you think we could bring these feature to Buchu?

@endersoncosta
Copy link
Contributor Author

endersoncosta commented May 18, 2020

I believe that the behavior must be the same, because the Programmer must express your intention to a nullable field... Then presence aways true, but with an option to overide and set as false...

@dalssoft
Copy link
Member

dalssoft commented Jun 8, 2020

regardless of discussion of the default behavior for nullables fields I believe we should have allowNull and presence options working on Buchu

@jhomarolo
Copy link
Contributor

Now that Suma validates Contains and notContains we can improve buchu with these validations as well.

@dalssoft
Copy link
Member

dalssoft commented Jun 8, 2020

@jhomarolo contains requires a value to be validated against, which is not the case. what @endersoncosta is proposing is check for null/empty which allowNull and presence is a better fit

@endersoncosta
Copy link
Contributor Author

At that moment, buchu accept undefined as a valid value, but reject null...

@dalssoft
Copy link
Member

dalssoft commented Jun 8, 2020

we have two options:
(1) - make the default behavior for null/empty the same across libs
(2) - make request from use case (buchu) have a different behavior

to me entities (gotu) and values (suma) should skip nulls since it is common to have partial data filling, specially for entities

for request it is usually the opposite: you want to make sure all the values are there to start processing the use case unless you explicit inform you want a field to be null/empty

with that I think the next step would leave the current behavior for the libs and improve buchu to refuse null/undefined and be able to use suma's options allowNull and presence on the request definition

@jhomarolo jhomarolo added enhancement New feature or request help wanted Extra attention is needed severity-nice-to-have Item is nice to have labels Dec 24, 2021
@italojs
Copy link
Member

italojs commented Apr 14, 2022

this issue is from jun 2020, this still make sense to maintain opened? @endersoncosta

@dalssoft
Copy link
Member

we have plent of systems running with Herbs since 2020. how we managed with this problem so far? @endersoncosta @jhomarolo ? workarounds? it is important to understand the patterns we created on top of this limitation

@jhomarolo
Copy link
Contributor

@VictorTBX given that you recently worked on a similar feature, can you tell us if this issue is still valid?

@VictorTBX
Copy link
Contributor

@jhomarolo partially, since we have the new feature for request we can manage which fields I want to receive, but an "allowNull" still may be valid in some scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed severity-nice-to-have Item is nice to have
Projects
None yet
Development

No branches or pull requests

5 participants