Giter VIP home page Giter VIP logo

Comments (7)

kataras avatar kataras commented on May 29, 2024 1

@frodgesh I'm not sure if I understand correctly but I'll try to answer you based on the question I can imagine that you're asking for;

Validator is just a function of form: func(ans interface{}) error , the ans is the answer given from the user by terminal and if the returned error is not nil then the answer is invalid and it asks again.

You can use it anywhere you like, remember they're just functions, the AskOne is just a helper which you can pass a nil on its third input argument if you don't want them.

You can use Validators all over the place, look the README.md example, it has a Validation: field on Question struct: https://github.com/AlecAivazis/survey/blob/master/survey.go#L28 but this doesn't limit you to use those functions in other places inside your project as well!

from survey.

AlecAivazis avatar AlecAivazis commented on May 29, 2024

@frodgesh thanks for submitting another issue. I'm slightly confused what exactly you're asking - do you mind providing a code block for the API you would like to see?

from survey.

 avatar commented on May 29, 2024

@AlecAivazis, sorry about my explanation. I'm just asking, if it's possible to use validation above the AskOne.

from survey.

 avatar commented on May 29, 2024

@kataras, I don't even know, how did I pass away the third argument, sorry for my clumsiness. And what about using Transform field in the helper's function?

from survey.

AlecAivazis avatar AlecAivazis commented on May 29, 2024

Thanks for helping out @kataras, I hope this clears things up for you @frodgesh.

I was just thinking about whether or not we wanted to include a Transformer as an arg to AskOne. Since Transformers are just normal functions, you can perform the transformation on the variable after calling AskOne.

FWIW, i opted to not add it as an arg to AskOne to avoid breaking the top-level API.

from survey.

kataras avatar kataras commented on May 29, 2024

No problem, yes I didn't add those on AskOne for the same reason, although I think that AskOne should be avoided because we can't add many input arguments as struct fields on the Ask(...,Question)

from survey.

 avatar commented on May 29, 2024

@kataras, you said the exact reason, why did I open the issue.

from survey.

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.