# BeanValidator

Import: `import com.install4j.api.beaninfo.BeanValidator;`

```java
interface BeanValidator
```

Interface for the [`Install4JBeanInfo.ATTRIBUTE_BEAN_VALIDATOR`](Install4JBeanInfo.md#attribute-bean-validator) value of a bean descriptor.
With a bean validator, you can check at design-time if the values of the bean properties are valid
and notify the user if this is not the case.

The [`Install4JBeanInfo`](Install4JBeanInfo.md) class offers a number of convenience methods to help bean validators to
quickly check common conditions. It is most convenient if you make the bean info implement the
`BeanValidator` interface itself, in that case the convenience methods are directly accessible.


**See also:**

- [Install4JBeanInfo.checkNotEmpty](Install4JBeanInfo.md#checknotempty-string-bean)
- [Install4JBeanInfo.checkNotEmpty](Install4JBeanInfo.md#checknotempty-string-string-bean)
- [Install4JBeanInfo.isEmpty](Install4JBeanInfo.md#isempty-string-bean)
- [Install4JBeanInfo.findPropertyDescriptor](Install4JBeanInfo.md#findpropertydescriptor-string)
- [Install4JBeanInfo.getPropertyValue](Install4JBeanInfo.md#getpropertyvalue-propertydescriptor-bean)

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`validateBean(Bean)`](#validatebean-bean) | `void` | Called by the install4j GUI at design-time to check the validity of the bean properties. |

### validateBean(Bean)

```java
void validateBean(Bean bean) throws BeanValidationException
```

Called by the install4j GUI at design-time to check the validity of the bean properties.
This method is called repeatedly when the user switches between different beans as well
as by the compiler.


**Parameters:**

- `bean` — the bean that should be validated

**Throws:**

- `BeanValidationException` — Throw this exception if the bean properties are not valid

