-
Notifications
You must be signed in to change notification settings - Fork 12
PortugueseNIFValidator
ajcamilo edited this page Dec 3, 2014
·
2 revisions
PortugueseNIFValidator is a custom Wicket validator that checks if the input is a valid NIF/ NIPC. According to the Portuguese law, a NIF/NIPC must be a unique 9 digits long number, starting with {1,2,5,6,8,9} which complies with the mod11 algorithm (Wikipedia).
Except for the passed parameters, there's no big difference between using PortugueseNIFValidator and any other simple Wicket validator, as you'll be able to see in the following example:
<form wicket:id="nifForm">
<label>NIF</label>:
<input wicket:id="nif" type="text"/>
<input type="submit" value="Validate" />
</form>
Form<?> form = new Form<Void>("nifForm") { ... }
final TextField<String> nifField = new TextField<String>("nif", Model.of(""));
nifField.setRequired(true);
nifField.add(new PortugueseNIFValidator());
form.add(nifField);
add(form);