|
|
|
@ -1,12 +1,12 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2007 the original author or authors. |
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* You may obtain a copy of the License at |
|
|
|
* You may obtain a copy of the License at |
|
|
|
* |
|
|
|
* |
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* |
|
|
|
* |
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
|
|
@ -18,21 +18,21 @@ package org.springframework.validation; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A validator for application-specific objects. |
|
|
|
* A validator for application-specific objects. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>This interface is totally divorced from any infrastructure |
|
|
|
* <p>This interface is totally divorced from any infrastructure |
|
|
|
* or context; that is to say it is not coupled to validating |
|
|
|
* or context; that is to say it is not coupled to validating |
|
|
|
* only objects in the web tier, the data-access tier, or the |
|
|
|
* only objects in the web tier, the data-access tier, or the |
|
|
|
* whatever-tier. As such it is amenable to being used in any layer |
|
|
|
* whatever-tier. As such it is amenable to being used in any layer |
|
|
|
* of an application, and supports the encapsulation of validation |
|
|
|
* of an application, and supports the encapsulation of validation |
|
|
|
* logic as first-class citizens in their own right. |
|
|
|
* logic as first-class citizens in their own right. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Find below a simple but complete <code>Validator</code> |
|
|
|
* <p>Find below a simple but complete <code>Validator</code> |
|
|
|
* implementation, which validates that the various {@link String} |
|
|
|
* implementation, which validates that the various {@link String} |
|
|
|
* properties of a <code>UserLogin</code> instance are not empty |
|
|
|
* properties of a <code>UserLogin</code> instance are not empty |
|
|
|
* (that is they are not <code>null</code> and do not consist |
|
|
|
* (that is they are not <code>null</code> and do not consist |
|
|
|
* wholly of whitespace), and that any password that is present is |
|
|
|
* wholly of whitespace), and that any password that is present is |
|
|
|
* at least <code>'MINIMUM_PASSWORD_LENGTH'</code> characters in length. |
|
|
|
* at least <code>'MINIMUM_PASSWORD_LENGTH'</code> characters in length. |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> public class UserLoginValidator implements Validator { |
|
|
|
* <pre class="code"> public class UserLoginValidator implements Validator { |
|
|
|
* |
|
|
|
* |
|
|
|
* private static final int MINIMUM_PASSWORD_LENGTH = 6; |
|
|
|
* private static final int MINIMUM_PASSWORD_LENGTH = 6; |
|
|
|
@ -53,17 +53,17 @@ package org.springframework.validation; |
|
|
|
* } |
|
|
|
* } |
|
|
|
* } |
|
|
|
* } |
|
|
|
* }</pre> |
|
|
|
* }</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>See also the Spring reference manual for a fuller discussion of |
|
|
|
* <p>See also the Spring reference manual for a fuller discussion of |
|
|
|
* the <code>Validator</code> interface and it's role in a enterprise |
|
|
|
* the <code>Validator</code> interface and it's role in a enterprise |
|
|
|
* application. |
|
|
|
* application. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rod Johnson |
|
|
|
* @author Rod Johnson |
|
|
|
* @see Errors |
|
|
|
* @see Errors |
|
|
|
* @see ValidationUtils |
|
|
|
* @see ValidationUtils |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public interface Validator { |
|
|
|
public interface Validator { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Can this {@link Validator} {@link #validate(Object, Errors) validate} |
|
|
|
* Can this {@link Validator} {@link #validate(Object, Errors) validate} |
|
|
|
* instances of the supplied <code>clazz</code>? |
|
|
|
* instances of the supplied <code>clazz</code>? |
|
|
|
@ -77,8 +77,8 @@ public interface Validator { |
|
|
|
* {@link #validate(Object, Errors) validate} instances of the |
|
|
|
* {@link #validate(Object, Errors) validate} instances of the |
|
|
|
* supplied <code>clazz</code> |
|
|
|
* supplied <code>clazz</code> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
boolean supports(Class clazz); |
|
|
|
boolean supports(Class<?> clazz); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Validate the supplied <code>target</code> object, which must be |
|
|
|
* Validate the supplied <code>target</code> object, which must be |
|
|
|
* of a {@link Class} for which the {@link #supports(Class)} method |
|
|
|
* of a {@link Class} for which the {@link #supports(Class)} method |
|
|
|
|