Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coder-acjhp/springmvc-maven-customannotations
Custom annotation
https://github.com/coder-acjhp/springmvc-maven-customannotations
javax-annotation javax-validation maven spring-mvc web-app
Last synced: 27 days ago
JSON representation
Custom annotation
- Host: GitHub
- URL: https://github.com/coder-acjhp/springmvc-maven-customannotations
- Owner: Coder-ACJHP
- Created: 2017-04-30T00:02:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-30T00:28:57.000Z (over 7 years ago)
- Last Synced: 2024-11-08T00:35:58.874Z (3 months ago)
- Topics: javax-annotation, javax-validation, maven, spring-mvc, web-app
- Language: Java
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Javax.validation (Custom annotations)
In this project we gonna create own validation annotation(s) and for example
we will use it in Spring MVC & Maven web application.Check this two classes :
1 : CourseCode
In this class we need to create
@Annotation class and give it some rules like : @Constraint("tell him from which class will gate rules"),
@Target("tell to app where it can use it like {ElementType.METHOD//in method, ElementType.FIELD//in fields}"), @Retention("tell to app what the policy like: RetentionPolicy.RUNTIME")
// define default course code
public String value() default "CoderACJHP";
// define default error code
public String message() default "must start with CoderACJHP";
// define default grups
public Class>[] groups() default {};
// define default peyloads
public Class extends Payload>[] payload() default {};
2: CourseCodeConstraintValidator
In this class we need to create validation logic it's very basic, just at first make the
class implements ConstraintValidator interface and implemet all methods and override them as you want.
That's it enjoy!
Thank you for reading this.