mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
added more validator type
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15083 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
d5f743c4ff
commit
ee7fd53b52
1 file changed
+23
@@ -610,4 +610,27 @@ public abstract class FormFieldValidator {
|
||||
error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the 'value' parameter is an integer >= 0.
|
||||
*
|
||||
* @since 1.282
|
||||
*/
|
||||
public static class NonNegativeInteger extends FormFieldValidator {
|
||||
public NonNegativeInteger() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
protected void check() throws IOException, ServletException {
|
||||
try {
|
||||
String value = request.getParameter("value");
|
||||
if(Integer.parseInt(value)<0)
|
||||
error(hudson.model.Messages.Hudson_NotAPositiveNumber());
|
||||
else
|
||||
ok();
|
||||
} catch (NumberFormatException e) {
|
||||
error(hudson.model.Messages.Hudson_NotANumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user