List of usage examples for org.apache.wicket.validation Validatable isValid
@Override public boolean isValid()
From source file:com.myamamoto.wicket.misc.compound.NotNullValidatorTest.java
License:Apache License
@Test @SuppressWarnings("unchecked") public void testNotNull() { NotNullValidator validator = new NotNullValidator("label"); Validatable<String> validatable = new Validatable<String>(null); validator.validate(validatable);//from w ww. j a va 2 s.c o m assertThat(validatable.isValid(), is(false)); }
From source file:com.myamamoto.wicket.misc.validator.JancodeValidatorTest.java
License:Apache License
@Test public void testTooShortError() { Validatable<String> validatable = new Validatable<String>(""); this.validator.validate(validatable); assertThat(validatable.isValid(), is(false)); }
From source file:com.myamamoto.wicket.misc.validator.JancodeValidatorTest.java
License:Apache License
@Test public void testContainsNotDigit() { String jancode = "abcdefghijklm"; Validatable<String> validatable = new Validatable<String>(jancode); this.validator.validate(validatable); assertThat(validatable.isValid(), is(false)); }
From source file:com.myamamoto.wicket.misc.validator.JancodeValidatorTest.java
License:Apache License
@Test public void testPotatochips() { // ???//from w w w.ja v a 2s . c o m String jancode = "4522646430318"; Validatable<String> validatable = new Validatable<String>(jancode); this.validator.validate(validatable); assertThat(validatable.isValid(), is(true)); }
From source file:com.myamamoto.wicket.misc.validator.JancodeValidatorTest.java
License:Apache License
@Test public void testInvalidPotatochips() { String jancode = "4522646430310"; Validatable<String> validatable = new Validatable<String>(jancode); this.validator.validate(validatable); assertThat(validatable.isValid(), is(false)); }
From source file:eu.clarin.cmdi.virtualcollectionregistry.service.impl.ReferenceValidator.java
License:Open Source License
public boolean validate(String value) { final Validatable<String> validatable = new Validatable<>(value); validate(validatable);// w w w. j a va 2 s . c o m return validatable.isValid(); }
From source file:eu.clarin.cmdi.virtualcollectionregistry.VirtualCollectionRegistryReferenceCheckImpl.java
License:Open Source License
/** * Check all resources of this vc against the reference validator. * Log an error message if validation fails. * /* ww w .j ava2 s . c o m*/ * @param vc * @return */ private ReferenceValidator checkValidityOfReferences(VirtualCollection vc) { ReferenceValidator validator = new ReferenceValidator(); for (Resource resource : vc.getResources()) { final Validatable<String> validatable = new Validatable<>(resource.getRef()); validator.validate(validatable); if (!validatable.isValid()) { for (IValidationError error : validatable.getErrors()) { //TODO: Does this actually print anything meaningful? logger.error("[RESOURCE ERROR] vc={}, error={}", vc.getId(), error.toString()); } } } return validator; }
From source file:jp.xet.uncommons.wicket.behavior.AbstractValidatorTest.java
License:Apache License
/** * ????{@code valid}?????//from w w w .j a v a 2 s . c o m * * @param validator ? * @param value * @param valid valid???????{@code true}?????????{@code false} * @throws NullPointerException ?{@code null}??? * @since 1.0 */ protected static <T> void assertValid(IValidator<T> validator, T value, boolean valid) { Preconditions.checkNotNull(validator); Validatable<T> target = new Validatable<T>(value); validator.validate(target); assertThat(target.isValid(), is(valid)); }
From source file:org.apache.openmeetings.util.mail.MailUtil.java
License:Apache License
public static boolean isValid(String email) { if (Strings.isEmpty(email)) { return false; }/*from ww w. ja v a 2 s. co m*/ Validatable<String> eml = new Validatable<>(email); RfcCompliantEmailAddressValidator.getInstance().validate(eml); return eml.isValid(); }
From source file:org.apache.openmeetings.web.util.UserChoiceProvider.java
License:Apache License
public static User getUser(String value) { User u = null;/*w w w .j a va 2 s.c om*/ if (!Strings.isEmpty(value)) { //FIXME refactor this String email = null; String fName = null; String lName = null; int idx = value.indexOf('<'); if (idx > -1) { int idx1 = value.indexOf('>', idx); if (idx1 > -1) { email = value.substring(idx + 1, idx1); String name = value.substring(0, idx).replace("\"", ""); int idx2 = name.indexOf(' '); if (idx2 > -1) { fName = name.substring(0, idx2); lName = name.substring(idx2 + 1); } else { fName = ""; lName = name; } } } else { email = value; } Validatable<String> valEmail = new Validatable<String>(email); RfcCompliantEmailAddressValidator.getInstance().validate(valEmail); if (valEmail.isValid()) { u = getBean(UserDao.class).getContact(email, fName, lName, getUserId()); } } return u; }