1 /*
2 * Copyright 2008 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.ole.module.purap.document.validation.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.sys.document.validation.GenericValidation;
20 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
21 import org.kuali.rice.kns.datadictionary.validation.fieldlevel.EmailAddressValidationPattern;
22 import org.kuali.rice.kns.datadictionary.validation.fieldlevel.PhoneNumberValidationPattern;
23
24 public class PurchasingAccountsPayableProcessVendorValidation extends GenericValidation {
25
26 public boolean validate(AttributedDocumentEvent event) {
27 return true;
28 }
29
30 /**
31 * validate the phone number against the phone pattern
32 *
33 * @param PhoneNumber
34 * @return true if phone number follows the pattern else return false.
35 */
36 public boolean validatePhoneNumber(String PhoneNumber) {
37 boolean valid = true;
38
39 //perform the validation against phone Number
40 if (StringUtils.isNotBlank(PhoneNumber)) {
41 PhoneNumberValidationPattern phonePattern = new PhoneNumberValidationPattern();
42 if (!phonePattern.matches(PhoneNumber)) {
43 return false;
44 }
45 }
46
47 return valid;
48 }
49
50 /**
51 * validate the email Address against the email address pattern
52 *
53 * @param emailAddress
54 * @return true if email Address follows the pattern else return false.
55 */
56 public boolean validateEmailAddress(String emailAddress) {
57 boolean valid = true;
58
59 //perform the validation against email address
60 if (StringUtils.isNotBlank(emailAddress)) {
61 EmailAddressValidationPattern emailAddressPattern = new EmailAddressValidationPattern();
62 if (!emailAddressPattern.matches(emailAddress)) {
63 return false;
64 }
65 }
66
67 return valid;
68 }
69 }