Docs Home / Compass / Interact with Your Data / Set Validation Rules

Generate Validation Rules生成验证规则

The Validation tab allows you to manage schema validation rules for a collection.“验证”选项卡允许您管理集合的模式验证规则

Schema validation ensures that all documents in a collection follow a defined set of rules, such as conforming to a specific shape or only allowing a specified range of values in fields.模式验证确保集合中的所有文档都遵循一组定义的规则,例如符合特定的形状或仅允许字段中的指定值范围。

For details, see Set Validation Rules for Your Schema.有关详细信息,请参阅为模式设置验证规则

Steps步骤

1

Generate rules生成规则

To generate validation rules, click Generate Rules.要生成验证规则,请单击“生成规则”。

Validation view
2

Apply rules应用规则

To apply the validation rules, click Apply. To go back, click Cancel.要应用验证规则,请单击“应用”。要返回,请单击“取消”。

3

(Optional) Preview sample documents(可选)预览示例文档

You can preview sample documents that match your validation rules by clicking Preview documents.通过单击“预览文档”,可以预览符合验证规则的示例文档。

4

Confirm rules确认规则

To confirm applying the validation rules, click Confirm. To go back, click Cancel.要确认应用验证规则,请单击“确认”。要返回,请单击“取消”。

Next Steps后续步骤

Learn More了解更多