-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPropertyValidator.java
38 lines (32 loc) · 1.03 KB
/
PropertyValidator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.db.mixing;
import sirius.kernel.di.std.AutoRegister;
import sirius.kernel.di.std.Named;
import java.util.function.Consumer;
/**
* Permits to validate a property before it is written to the database.
*/
@AutoRegister
public interface PropertyValidator extends Named {
/**
* Validates the given value and reports any warnings/errors to the given consumer.
*
* @param value the value to validate
* @param validationConsumer can be used to report validation errors
*/
void validate(Property property, Object value, Consumer<String> validationConsumer);
/**
* Validates the given value and reports any warnings/errors to the given consumer.
* <p>
* Throwing any exception will abort the write operation.
*
* @param value the value to validate
*/
void beforeSave(Property property, Object value);
}