
de.knightsoftnet.validators.shared.AlternateSize Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package de.knightsoftnet.validators.shared;
import de.knightsoftnet.validators.shared.impl.AlternateSizeValidator;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
/**
* The annotated element size must be exactly match size1 or size2.
* Supported types are Strings null
elements are considered valid.
* With the following options separator characters can be removed before size is checked:
*
* - ignoreWhiteSpaces (true/false, default false)
* - ignoreMinus (true/false, default false)
* - ignoreSlashes (true/false, default false)
*
*
* @author Manfred Tremmel
*
*/
@Documented
@Constraint(validatedBy = AlternateSizeValidator.class)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface AlternateSize {
/**
* localized message.
*
* @return localized validation message
*/
String message() default "{de.knightsoftnet.validators.shared.AlternateSize.message}";
/**
* groups to use.
*
* @return array of validation groups
*/
Class>[] groups() default {};
/**
* first possible size.
*
* @return first possible size
*/
int size1();
/**
* second possible size.
*
* @return second possible size
*/
int size2();
/**
* true if white spaces should be ignored.
*
* @return true if white spaces should be ignored
*/
boolean ignoreWhiteSpaces() default false;
/**
* true if minus should be ignored.
*
* @return true if minus should be ignored
*/
boolean ignoreMinus() default false;
/**
* true if slashes should be ignored.
*
* @return true if slashes should be ignored
*/
boolean ignoreSlashes() default false;
/**
* payload whatever.
*
* @return payload class
*/
Class extends Payload>[] payload() default {};
/**
* Defines several {@code AlternateSize} annotations on the same element.
*/
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface List {
/**
* alternate size value.
*
* @return value
*/
AlternateSize[] value();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy