> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# arc:validate

> 使用 arc:validate 在对象缺少必需属性时抛出错误，并可配置错误代码和描述。

export const siteNameShort = "知行之桥";

可以使用 `arc:validate` 关键字在缺少必需值时抛出错误。

## 参数

* **item**：包含要验证属性的对象。
* **attr**：要验证的属性。如果该属性不存在，则抛出错误。
* **code**：验证失败时要抛出的错误码。默认值：`arc:validate`。
* **desc**：验证失败时要抛出的错误描述。默认消息说明指定的属性是必需的。

## 示例

如果 `_query` 对象不包含 `Id` 属性，则抛出一条更具体的消息：

```xml theme={null}
<arc:validate attr="_query.Id"   desc="The Id is required to delete."/>
```

## 另请参阅

* [arc:throw](./op-arc-throw)：从脚本中抛出错误（异常）。
