1 /** 2 * Copyright 2005-2013 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.krad.datadictionary.validation.constraint; 17 18 import org.kuali.rice.krad.datadictionary.parse.BeanTag; 19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 20 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace; 21 22 /** 23 * This is a constraint that limits attribute values to some subset of valid characters or to match a particular 24 * regular 25 * expression. 26 * 27 * For example: 28 * - To limit to both upper and lower-case letters, value can be set to "[A-Za-z]*" 29 * - To limit to any character except carriage returns and line feeds, value can be set to "[^\n\r]*" 30 * 31 * @author Kuali Rice Team (rice.collab@kuali.org) 32 */ 33 @BeanTag(name = "validCharactersConstraint-bean", parent="ValidCharactersConstraint") 34 public class ValidCharactersConstraint extends BaseConstraint { 35 36 protected String value; 37 38 /** 39 * The Java based regex for valid characters 40 * This value should include the ^ and $ symbols if needed 41 * 42 * @return the value 43 */ 44 @BeanTagAttribute(name = "value") 45 public String getValue() { 46 return value; 47 } 48 49 /** 50 * @param value the value to set 51 */ 52 public void setValue(String value) { 53 this.value = value; 54 } 55 56 /** 57 * Validates different requirements of component compiling a series of reports detailing information on errors 58 * found in the component. Used by the RiceDictionaryValidator. 59 * 60 * @param tracer Record of component's location 61 */ 62 @Override 63 public void completeValidation(ValidationTrace tracer) { 64 tracer.addBean("ValidCharacterConstraint", getMessageKey()); 65 66 if (getValue() == null) { 67 String currentValues[] = {"getValue =" + getValue()}; 68 tracer.createWarning("GetValue should return something", currentValues); 69 } 70 71 super.completeValidation(tracer.getCopy()); 72 } 73 }