提交 ee7fd53b 编写于 作者: K kohsuke

added more validator type

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15083 71c3de6d-444a-0410-be80-ed276b4c234a
上级 d5f743c4
......@@ -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());
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册