1 package org.sapia.validator.rules; 2 3 import org.sapia.validator.Rule; 4 import org.sapia.validator.ValidationContext; 5 6 10 public class TestRule extends Rule { 11 private boolean _wasCalled; 12 private boolean _createError; 13 14 17 public TestRule(boolean createError) { 18 _createError = createError; 19 } 20 21 public void reset() { 22 _wasCalled = false; 23 } 24 25 public boolean wasCalled() { 26 return _wasCalled; 27 } 28 29 32 public void validate(ValidationContext context) { 33 _wasCalled = true; 34 35 if (_createError) { 36 context.getStatus().error(this); 37 } 38 } 39 } 40 | Popular Tags |