All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generator.server.javatool.base.main.assertions.md.mustache Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
# Assertions

The `Assert` class contains some utilities to make some basic input checks.

Those assertions are done at runtime, and they will result in an exception if the condition is not met. Considering the slow feedback loop we recommend first relying on types for input validations (so you'll have a compile time checks).

Those assertions are designed for very simple, technical related checks. If you want to make business facing checks, you should create your own exceptions && check mechanism dedicated to business validations.

## Usage

There are 2 ways of doing assertions, the first is "simple checks":

```java
Assert.notNull("field", value);
```

The first parameter is the name of the parameter (used in the exception message) and the second one is the value to check. In this first usage, you check a simple condition.

You can also use the `Assert` class with types specific checks:

```java
Assert.field("name", name)
  .notBlank()
  .maxLength(150);
```




© 2015 - 2024 Weber Informatics LLC | Privacy Policy