Validator¶
lcp.validator ¶
Validator module for LCP documents.
LCPValidationError ¶
Bases: Exception
Exception raised when LCP validation fails.
Source code in src/lcp/validator.py
validate_dict ¶
Validate a dictionary against the LCP v1 schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The LCP document as a dictionary. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of validation error messages. Empty list if valid. |
Source code in src/lcp/validator.py
validate_document ¶
Validate an LCPDocument against the LCP v1 schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
LCPDocument
|
The LCPDocument to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of validation error messages. Empty list if valid. |
Source code in src/lcp/validator.py
validate_file ¶
Validate an LCP file against the LCP v1 schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the LCP JSON file. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of validation error messages. Empty list if valid. |
Source code in src/lcp/validator.py
is_valid ¶
Check if an LCP document is valid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
LCPDocument | dict[str, Any]
|
The LCPDocument or dictionary to validate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if valid, False otherwise. |
Source code in src/lcp/validator.py
validate_or_raise ¶
Validate an LCP document and raise if invalid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
LCPDocument | dict[str, Any]
|
The LCPDocument or dictionary to validate. |
required |
Raises:
| Type | Description |
|---|---|
LCPValidationError
|
If the document is invalid. |