Code Monkey home page Code Monkey logo

Comments (6)

raphael avatar raphael commented on May 27, 2024

I believe what's happening here is that the Goa generated CLI uses the service type to load the JSON passed on the command line. Because the attribute is required the corresponding field does not use a pointer and so defaults to 0. So the server gets an object with the field set to 0, it is not missing and validation does not fail. To convince yourself use another client tool (e.g. httpie) that won't initialize required fields to their zero value if not explicitly defined.

from goa.

t-hale avatar t-hale commented on May 27, 2024

That was what I was afraid was happening - is there a way to avoid this besides not using goa? I feel like I'm missing something because this makes it seem like having a Required type isn't possible with a goa cli/server combo?

from goa.

raphael avatar raphael commented on May 27, 2024

This is just the CLI code behaving that way when loading bodies from the JSON in the terminal - not the underlying server or client packages so any service making use of these packages won't have this issue.

from goa.

t-hale avatar t-hale commented on May 27, 2024

Understood, but one of the reasons I'd like to use goa is that it will generate both the cli and server for me. Having to write/maintain a CLI separately from the goa-generated one is taking away one of the main selling points for me. I will look into some of the other validation functions to see if I can work around it in the short term, but would love to see if there is a better long term fix.

Similar to #687

from goa.

raphael avatar raphael commented on May 27, 2024

Makes sense, I'd be happy to consider / help putting together a PR that improved this. We may need to generate special types for the CLI instead of relying on the existing service level types to perform that kind of validation.

from goa.

github-actions avatar github-actions commented on May 27, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

from goa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.