Skip to content

Support for parameter validation #47

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

Open
ctrueden opened this issue May 1, 2014 · 1 comment
Open

Support for parameter validation #47

ctrueden opened this issue May 1, 2014 · 1 comment

Comments

@ctrueden
Copy link
Member

ctrueden commented May 1, 2014

Many RIA frameworks make it easy to validate a form's parameter values before executing some business logic. For example, if a string must conform to a certain regex, the UI can present a message to the user (ideally integrated with the form itself) informing them of the invalid value, and asking for a correction, rather than simply failing during execution.

We would like to provide similar functionality for ImageJ commands. One approach would be to have an optional validation callback for each parameter that returns an object describing any validation errors that occurred (error message, type of error, etc.), which the UI-specific input harvester can then present to the user.

Migrated-From: http://trac.imagej.net/ticket/1564

@imagejan
Copy link
Member

imagejan commented Jul 4, 2017

In a DynamicCommand, you can use a callback annotation to call methods that change values of inputs (and messages in case of visibility=MESSAGE).

For scripts, this is more difficult since the script methods are not yet known at preprocessing time, when the input harvesting happens. Maybe we could introduce some kind of "light" callbacks in the style of lambda expressions or simple boolean expressions, e.g.:

#@ boolean processDecimalPoint
#@ int    (visibility = "processDecimalPoint == false") integerInput
#@ double (visibility = "processDecimalPoint == true") doubleInput

#@ String (choices = {"files", "folder"}) folderChoice
#@ File   (style = "directory", visibility = "folderChoice.equals('folder')") singleFileInput
#@ File[] (visibility = "folderChoice.equals('files')") fileListInput

This requires improving the options for parameter visibility, see #42.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants