Property Constraints and Validation
Data Standard leverages the property constraints configured in property definitions.
Constraints
You can add custom properties, and modify or override existing property constraints from Vault.
To modify constraints, use for example $Prop["Title"].IsObligatory = $true
.
To add properties, use $Prop["CustomProperty"].Value = "somevalue"
. For Inventor and AutoCAD, the new property will be saved as custom property when you save the document.
- In the Default.ps1 file, add the new required property, for example: $Prop["SomeProperty"].IsObligatory = $true
- Open a Data Standard client in Vault, Inventor or AutoCAD.
- Display the Data Standard dialog.
- The edited field with the required property is highlighted in red border indicating that the input is necessary.
Validation
You can add custom validation to properties. This allows to validate against custom constraints defined in particular functions.
To add a custom validation, use $Prop["CustomProperty"].CustomValidation = { MyValidation }
. The function “MyValidation” has to return $true or $false, based on your custom constraints.
Validation - Examples
CAD: Review the powerShell script .\CAD\addins\FileNameValidation.ps1 installed with Vault Data Standard Inventor / AutoCAD.
Vault: Review sample code in the configuration - Example–Add Custom Validation for FolderNames.