001package model.validation;
002
003import javax.validation.Constraint;
004import javax.validation.Payload;
005import javax.validation.constraints.Pattern;
006import javax.validation.constraints.Size;
007import java.lang.annotation.*;
008
009/**
010 * Il formato del nome utente deve essere valido
011 */
012@Pattern(regexp = "^[\\w\\-]+$")
013@Size(min=3, max=30)
014@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER,
015        ElementType.ANNOTATION_TYPE})
016@Retention(RetentionPolicy.RUNTIME)
017@Constraint(validatedBy = {})
018@Documented
019public @interface UsernameFormat {
020    String message() default "Formato username non valido";
021
022    Class<?>[] groups() default {};
023
024    Class<? extends Payload>[] payload() default {};
025}