@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { return this.createVerifierRuleTemplate(config, context, "Invalid_Field_Constraint", null, "The field can not be used in this rule"); //I18N }
public String getMin(ConstraintConfiguration conf) { try { return (String) this.getMandatoryArgument(RANGE_CONSTRAINT_MIN, conf); } catch (ArgumentNotSetException e) { throw new IllegalStateException(e); } }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { List<String> constraints = new ArrayList<String>(); constraints.add("valueType != Field.INT"); return this.createVerifierRuleTemplate(config, context, "Integer_Field_Constraint", constraints, "The value must be an integer"); //I18N }
public Constraint buildConstraint(ConstraintConfiguration config) { if (NotNullConstraint.NAME.equals(config.getConstraintName())) { return new NotNullConstraint(); } else if (IntegerConstraint.NAME.equals(config.getConstraintName())) { return new IntegerConstraint(); } else if (RangeConstraint.NAME.equals(config.getConstraintName())) { return new RangeConstraint(); } else if (NotMatchesConstraint.NAME.equals(config.getConstraintName())) { return new NotMatchesConstraint(); }else if (MatchesConstraint.NAME.equals(config.getConstraintName())) { return new MatchesConstraint(); }else if (InvalidFieldConstraint.NAME.equals(config.getConstraintName())) { return new InvalidFieldConstraint(); }else if (MandatoryFieldConstraint.NAME.equals(config.getConstraintName())) { return new MandatoryFieldConstraint(); } else { throw new IllegalArgumentException("Constraint unknown: " + config.getConstraintName()); } }
@Before public void setup() { conf = new SimpleConstraintConfigurationImpl(); conf.setFactType("Person"); conf.setFieldName("name"); cons = new NotNullConstraint(); }
@Before public void setup() { cons = new RangeConstraint(); conf = new SimpleConstraintConfigurationImpl(); conf.setFactType("Person"); conf.setFieldName("age"); }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { List<String> constraints = new ArrayList<String>(); constraints.add("valueType == Field.UNKNOWN"); return this.createVerifierRuleTemplate(config, context, "Not_null_Field_Constraint", constraints, "The value could not be null"); // I18N }
protected Object getMandatoryArgument(String key) throws ArgumentNotSetException { if (!this.arguments.containsKey(key)) { throw new ArgumentNotSetException("The argument " + key + " doesn't exist."); } Object value = this.getArgumentValue(key); if (value == null) { throw new ArgumentNotSetException("The argument " + key + " is null."); } return value; }
public String getVerifierRule(ConstraintConfiguration config) { StringTemplate ruleTemplate = new StringTemplate(this.getTemplate()); ruleTemplate.setAttribute("uuid", UUID.randomUUID().toString()); ruleTemplate.setAttribute("factType", config.getFactType()); ruleTemplate.setAttribute("fieldName", config.getFieldName()); return ruleTemplate.toString(); }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { List<String> constraints = new ArrayList<String>(); constraints.add("valueAsString matches \"" + config.getArgumentValue(NOT_MATCHES_ARGUMENT) + "\""); return this.createVerifierRuleTemplate(config, context, "Matches_Field_Constraint", constraints, "The value must not match: " + config.getArgumentValue(NOT_MATCHES_ARGUMENT)); // I18N }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { List<String> constraints = new ArrayList<String>(); constraints.add("valueAsString not matches \"" + config.getArgumentValue(MATCHES_ARGUMENT) + "\""); return this.createVerifierRuleTemplate(config, context, "Matches_Field_Constraint", constraints, "The value must match: " + config.getArgumentValue(MATCHES_ARGUMENT)); // I18N }
public Constraint buildConstraint(ConstraintConfiguration config) { if (NotNullConstraint.NAME.equals(config.getConstraintName())) { return new NotNullConstraint(); } else if (IntegerConstraint.NAME.equals(config.getConstraintName())) { return new IntegerConstraint(); } else if (RangeConstraint.NAME.equals(config.getConstraintName())) { return new RangeConstraint(); } else if (NotMatchesConstraint.NAME.equals(config.getConstraintName())) { return new NotMatchesConstraint(); }else if (MatchesConstraint.NAME.equals(config.getConstraintName())) { return new MatchesConstraint(); }else if (InvalidFieldConstraint.NAME.equals(config.getConstraintName())) { return new InvalidFieldConstraint(); }else if (MandatoryFieldConstraint.NAME.equals(config.getConstraintName())) { return new MandatoryFieldConstraint(); } else { throw new IllegalArgumentException("Constraint unknown: " + config.getConstraintName()); } }
public String getMax(ConstraintConfiguration conf) { try { return (String) this.getMandatoryArgument(RANGE_CONSTRAINT_MAX, conf); } catch (ArgumentNotSetException e) { throw new IllegalStateException(e); } }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { return this.createVerifierRuleTemplate(config, context, "Invalid_Field_Constraint", null, "The field can not be used in this rule"); //I18N }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { List<String> constraints = new ArrayList<String>(); constraints.add("valueType != Field.INT"); return this.createVerifierRuleTemplate(config, context, "Integer_Field_Constraint", constraints, "The value must be an integer"); //I18N }
@Override protected String internalVerifierRule(ConstraintConfiguration config, Map<String, Object> context) { List<String> constraints = new ArrayList<String>(); constraints.add("valueType == Field.UNKNOWN"); return this.createVerifierRuleTemplate(config, context, "Not_null_Field_Constraint", constraints, "The value could not be null"); // I18N }
protected Object getMandatoryArgument(String key) throws ArgumentNotSetException { if (!this.arguments.containsKey(key)) { throw new ArgumentNotSetException("The argument " + key + " doesn't exist."); } Object value = this.getArgumentValue(key); if (value == null) { throw new ArgumentNotSetException("The argument " + key + " is null."); } return value; }
public String getVerifierRule(ConstraintConfiguration config) { StringTemplate ruleTemplate = new StringTemplate(this.getTemplate()); ruleTemplate.setAttribute("uuid", UUID.randomUUID().toString()); ruleTemplate.setAttribute("factType", config.getFactType()); ruleTemplate.setAttribute("fieldName", config.getFieldName()); return ruleTemplate.toString(); }
public String getMin(ConstraintConfiguration conf) { try { return (String) this.getMandatoryArgument(RANGE_CONSTRAINT_MIN, conf); } catch (ArgumentNotSetException e) { throw new IllegalStateException(e); } }
public String getMax(ConstraintConfiguration conf) { try { return (String) this.getMandatoryArgument(RANGE_CONSTRAINT_MAX, conf); } catch (ArgumentNotSetException e) { throw new IllegalStateException(e); } }