Skip to main content

io.enterpriseai.contracts.ContractValidator

Source: sdks/java/enterprise-ai-java/src/main/java/io/enterpriseai/contracts/ContractValidator.java. Back to the Java SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Class ContractValidator​

Client side validation against the embedded copy of contracts/v1 (JSON Schema 2020-12). Manifests are detected by kind (Agent, Model, Tool, Skill, Plugin, Connector, Channel, ManagedComponent).

Attributes:

NameTypeRequiredDescription
BASE_URIStringyesBase URI of the schemas, https://schemas.enterprise-ai.io/v1/, mapped to the embedded copies.

Constructor ContractValidator​

ContractValidator(Locale locale)

Creates a validator that reads the embedded contract index and writes its messages in the given language.

NameTypeDefaultRequiredDescription
localeLocaleyesLanguage of the validation error messages, for example Locale.FRENCH.

ContractValidator.contracts​

List<String> contracts()

Contract names known by the embedded index.

This element takes no parameter.

Returns: List<String>. The unmodifiable list of contract names, such as tool-manifest.

ContractValidator.schema​

JsonNode schema(String name)

Reads the embedded JSON Schema of a contract.

NameTypeDefaultRequiredDescription
nameStringyesName of a contract of the index; an unknown name raises IllegalArgumentException.

Returns: JsonNode. The JSON Schema of the contract, as a JsonNode.

Raises: IllegalStateException.

ContractValidator.validate​

ValidationResult validate(String name, Object document)

Validates any value (JsonNode, Map, record) against a named contract.

NameTypeDefaultRequiredDescription
nameStringyesName of the contract, such as tool-manifest; an unknown name raises IllegalArgumentException.
documentObjectyesValue to validate: a JsonNode, a Map or a record converted to JSON.

Returns: ValidationResult. A ValidationResult: Result of a contract validation.

ContractValidator.validateManifest​

ValidationResult validateManifest(Object manifest)

Validates a manifest, picking the contract from its kind.

NameTypeDefaultRequiredDescription
manifestObjectyesManifest to validate; its kind picks the contract, an unknown kind gives an invalid result for the unknown contract.

Returns: ValidationResult. A ValidationResult: Result of a contract validation.