> For the complete documentation index, see [llms.txt](https://jnosql.gitbook.io/jnosql-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jnosql.gitbook.io/jnosql-book/pt-br/part4/chapter4_5.md).

# Bean Validation

O Artemis tem suporte o uso de bean validation, ele suporta como um plugin que, basicamente, escuta o evento de preEntity e executa o bean validation. O artemis-validation tem suporte ao bean validation, mas ele não o implementa, em outras palavras, é necessário adicionar tanto a API quanto a uma implementação do bean validation no projeto.

```java
@Entity
public class Person {

    @Key
    @NotNull
    @Column
    private String name;

    @Min(21)
    @NotNull
    @Column
    private Integer age;

    @DecimalMax("100")
    @NotNull
    @Column
    private BigDecimal salary;

    @Size(min = 1, max = 3)
    @NotNull
    @Column
    private List<String> phones;
}
```

Caso seja encontrado um problema na validação no projeto ele lançará uma exceção do tipo ConstraintViolationException.

```java
 Person person = Person.builder()
                .withAge(10)
                .withName("Ada")
                .withSalary(BigDecimal.ONE)
                .withPhones(singletonList("123131231"))
                .build();
repository.save(person);//throws a ConstraintViolationException
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jnosql.gitbook.io/jnosql-book/pt-br/part4/chapter4_5.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
