Represents the result of the form field validation.
Use one of the factory methods to create an instance, then return it from your doCheckXyz method. (Via {@link HttpResponse}, the returned object will render the result into {@link StaplerResponse}.) This way of designing form field validation allows you to reuse {@code doCheckXyz()} methodsprogrammatically as well (by using {@link #kind}.
For typical validation needs, this class offers a number of {@code validateXXX(...)} methods, such as{@link #validateExecutable(String)}. {@link FilePath} also has a number of {@code validateXXX(...)} methodsthat you may be able to reuse.
Also see {@link CVSSCM.DescriptorImpl#doCheckCvsRoot(String)} as an example.
This class extends {@link IOException} so that it can be thrown from a method. This allows one to reusethe checking logic as a part of the real computation, such as:
String getAntVersion(File antHome) throws FormValidation { if(!antHome.isDirectory()) throw FormValidation.error(antHome+" doesn't look like a home directory"); ... return IOUtils.toString(new File(antHome,"version")); } ... public FormValidation doCheckAntVersion(@QueryParameter String f) { try { return ok(getAntVersion(new File(f))); } catch (FormValidation f) { return f; } } ... public void {@linkplain Builder#perform(AbstractBuild,Launcher,BuildListener) perform}(...) { String version = getAntVersion(antHome); ... }
@author Kohsuke Kawaguchi
@since 1.294