Skip to content

How to create a question that would Round number and convert to string. #2259

Answered by jan-molak
tfarrar asked this question in How to... ?
Discussion options

You must be logged in to vote

There are three ways to do it:

  • inline, applicable if the data transformation is simple, or you're not planning to reuse it
  • using a custom mapping function, if the data transformation is more complex, or you're planning to reuse it
  • using a custom question, if the data transformation involves multiple steps, you need an actor instance to perform the transformation, and inline operations are insufficient

Inline transformation

Question.about, used by all the built-in Serenity/JS APIs, produces a QuestionAdapter, which proxies the methods and fields of the wrapped object recursively, allowing them to be used as either a Question (or an Interaction).

Assuming that your implementation of MyNotes

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tfarrar
Comment options

Answer selected by jan-molak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
Converted from issue

This discussion was converted from issue #2256 on February 29, 2024 00:28.