Annotations · 3.1.0
Validators & Verifiers
A comment guides the model; a declaration on the field is what the engine enforces. Every check runs before a value is set, without the chat model: a refused value is never saved, and the user gets one plain sentence — the declared message, else the check's own.
Named validators
A general format, checked on the value itself. Each takes an optional message.
| Annotation | The value must be |
|---|---|
| @Confiqure.Email | an email address |
| @Confiqure.NAPhoneNumber | a North American phone number: 10 digits, or 11 with a leading 1 |
| @Confiqure.UKPhoneNumber | a UK phone number: the national form starting with 0, or the international form starting with +44 |
| @Confiqure.WorldPhoneNumber | a phone number in international form: an optional +, then 7 to 15 digits |
| @Confiqure.USZipCode | a US ZIP code: 5 digits, or ZIP+4 (12345-6789) |
Spaces, dashes, dots and parentheses are allowed in phone numbers. Ranges and sizes (@Min, @Max, @Size) are not enforced by confiqure: write them in the field's comment, and the model follows them.
Confiqure checks
Run by confiqure, with no call to you: @Confiqure.Verify(ValidatorKind.…).
ADDRESSchecks a postal address and saves its corrected form at once. The engine recognises the parts by these field names: street or addressLine1 or line1, addressLine2, city, state or region, postalCode or zip, country; a String field takes the whole address as one line.PRODUCT_CODEaccepts a GTIN-8, -12, -13 or -14 with a valid check digit (UPC-A, EAN-13 and ISBN-13 are GTINs), an ISBN-10 with a valid check digit (Xallowed last), or an ASIN (B0followed by 8 letters or digits). Spaces and dashes are ignored.
@Confiqure.Setting(end = "/warehouse-settings")
public class WarehouseSettings {
@Confiqure.Email
private String contactEmail;
@Confiqure.USZipCode(message = "Give a 5-digit ZIP code.")
private String warehouseZip;
@Confiqure.Verify(Confiqure.ValidatorKind.ADDRESS)
private Address shipFrom;
@Confiqure.Verify(Confiqure.ValidatorKind.PRODUCT_CODE)
private String barcode;
}Your own checks
A check only your application can make — a code exists in your catalog, an account is open — is a tool class implementing one of two interfaces.
| Interface | Attach with | It answers |
|---|---|---|
| ConfiqureValidator<T> | @Confiqure.ValidatedBy(X.class) | ok, or not ok with a message — a format check |
| ConfiqureVerifier<T> | @Confiqure.VerifiedBy(Y.class) | ok, not ok with a message, or a corrected value, which is saved instead and stated |
@Confiqure.Tool
@RestController
public class CatalogCheck implements ConfiqureVerifier<String> {
@PostMapping("/checks/catalog")
public Confiqure.Verdict<String> verify(@RequestBody Confiqure.Check<String> check) {
String code = check.getValue().strip().toUpperCase();
if (!catalog.exists(code)) return Confiqure.Verdict.notOk("No product has the code " + code + ".");
return code.equals(check.getValue()) ? Confiqure.Verdict.ok() : Confiqure.Verdict.corrected(code);
}
}
// on a field of any object or request class
@Confiqure.VerifiedBy(CatalogCheck.class)
private String productCode;- The engine POSTs
{field, value, confiqureKey?}to the mappedvalidate/verify—confiqureKeyis the record's key when the record exists — and reads back{ok, message?, value?}. Build the answer withVerdict.ok(),notOk(message)orcorrected(value). - A validator answers
Verdict<Void>, so it cannot correct a value; that is a verifier. The compiler checks that the class you attach is the right kind. @Confiqure.VerifiedByon a request class checks the whole request once every field is set, before the operation is called:valueis the request object,fieldthe class's simple name. Not ok makes no call.
confiqure push (CLI 1.1.0) stops, naming the file and line, when the engine could not call your check:
- the value is not a class literal;
- the class is not a
@Confiqure.Toolclass in the push, or two tool classes share its name; - its
@Confiqure.Tool(name)differs from its class name; validate/verifyis missing,@Confiqure.Browseror@Confiqure.Async— a check answers at once from your server.
Versions
These need ai.confiqure:confiqure-annotation-java 3.1.0 and @confiqure/cli 1.1.0. Coming from CLI 0.5, move your classes to the 3.0 vocabulary first; tool classes then ship with every push.
Next:
Tool Classes
Operations the chat can call, and the confirmation card.
confiqure push
What the scan ships and what stops a push.