Annotations don't actually do anything on their own. They just let you tag up a piece of code with instructions or information that can be read by some other tool. That tool might be a compiler plugin or a runtime library that works using reflection. So what you're describing is possible, but you'd need an additional tool to actually perform the validation. There are some libraries available for that, but it depends what type of project you're working on.