Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
OwnerValidator.java
Package: petclinic.rar [view]
Upload User: dezhong
Upload Date: 2022-08-10
Package Size: 167k
Code Size: 1k
Category:
Java Develop
Development Platform:
Java
- package org.springframework.samples.petclinic.validation;
- import org.springframework.samples.petclinic.Owner;
- import org.springframework.util.StringUtils;
- import org.springframework.validation.Errors;
- /**
- * <code>Validator</code> for <code>Owner</code> forms.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- */
- public class OwnerValidator {
- public void validate(Owner owner, Errors errors) {
- if (!StringUtils.hasLength(owner.getFirstName())) {
- errors.rejectValue("firstName", "required", "required");
- }
- if (!StringUtils.hasLength(owner.getLastName())) {
- errors.rejectValue("lastName", "required", "required");
- }
- if (!StringUtils.hasLength(owner.getAddress())) {
- errors.rejectValue("address", "required", "required");
- }
- if (!StringUtils.hasLength(owner.getCity())) {
- errors.rejectValue("city", "required", "required");
- }
- String telephone = owner.getTelephone();
- if (!StringUtils.hasLength(telephone)) {
- errors.rejectValue("telephone", "required", "required");
- }
- else {
- for (int i = 0; i < telephone.length(); ++i) {
- if ((Character.isDigit(telephone.charAt(i))) == false) {
- errors.rejectValue("telephone", "nonNumeric", "non-numeric");
- break;
- }
- }
- }
- }
- }