One policy, two controls
Protect stores one standard JSON Schema with each document library. That policy can control both:
- Native SharePoint validation — Protect translates supported rules into SharePoint list or column validation, so the policy still applies when people edit metadata through SharePoint.
- Fill properties — Protect can read a file name or another configured value, split it into metadata, show the result for review, and update selected files.
The two controls are deliberately synchronized. Protect does not accept an Autofill rule unless it can publish an equivalent SharePoint rule for every destination value.
Before you configure a policy
You need:
- the Protect command extension installed on the SharePoint site;
- Manage Lists permission for the target library;
- every destination column created in the library before saving the policy; and
- writable columns of a supported type, such as text, multiline text, choice, number, currency, whole number, yes/no, or date/time.
Protect does not create helper columns. The internal names in the JSON Schema must match existing SharePoint column internal names.
If a target column already has validation that Protect does not manage, Protect stops the save instead of replacing that rule.
Create or change a policy
- Open the target document library.
- On the command bar, select Manage columns.
- Use Preview to review the current policy in plain language.
- Open JSON and enter or update the library's JSON Schema.
- Use Reference to check the supported rules and examples.
- Return to Preview and verify each display name, internal name, validation rule, enforcement location, Autofill source, and required state.
- Select Save.
During save, Protect validates the schema, checks the destination columns, creates an exact SharePoint validation plan, publishes the native formulas, and stores the JSON Schema with the library. If any part cannot be completed, the policy is not published as a weaker partial rule.
Example naming policy
This policy copies the complete file name into Title, separates that value into project, system, document number, and extension, and constrains every generated value:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Project document policy",
"description": "Use the approved project document naming structure and metadata values.",
"type": "object",
"required": ["Title", "Project", "System", "DocumentNumber", "FileExtension"],
"properties": {
"FileLeafRef": {
"title": "File name",
"type": "string",
"readOnly": true,
"pattern": "^(?<Title>.+)quot;
},
"Title": {
"title": "Naming ID",
"type": "string",
"pattern": "^(?<Project>[^-]+)-(?<System>[^-]+)-(?<DocumentNumber>[^.]+)\\.(?<FileExtension>[^.]+)quot;
},
"Project": {
"title": "Project",
"type": "string",
"pattern": "^[A-Z0-9]{3}quot;
},
"System": {
"title": "System",
"type": "string",
"enum": ["ARC", "STR", "MEP"]
},
"DocumentNumber": {
"title": "Document number",
"type": "string",
"pattern": "^[0-9]{3}quot;
},
"FileExtension": {
"title": "File extension",
"type": "string",
"enum": ["pdf", "xlsx", "png"]
}
}
}
For ABC-ARC-001.pdf, Fill properties proposes:
| Column | Proposed value |
|---|---|
| Naming ID | ABC-ARC-001.pdf |
| Project | ABC |
| System | ARC |
| Document number | 001 |
| File extension | pdf |
Named captures define structure only. Use .+ to copy a complete value or a delimiter form such as [^-]+ to split it. Put the actual allowed values and formats on the destination properties so Protect can reproduce them in SharePoint.
Create a validation-only policy
Autofill is optional. A schema with constrained metadata properties and no named captures publishes native validation only:
{
"type": "object",
"required": ["System", "DocumentNumber"],
"properties": {
"System": {
"type": "string",
"enum": ["ARC", "STR", "MEP"]
},
"DocumentNumber": {
"type": "string",
"pattern": "^[0-9]{3}quot;
}
}
}
Use this form when people enter the values manually but SharePoint must reject missing or invalid metadata.
Apply the policy to existing files
Native SharePoint validation applies when an item is written; it doesn't repair existing metadata. Use Fill properties when a saved policy includes named-capture extraction rules and selected files need to be brought into line.
See Fill properties for selected files for file selection, field editing, row validation, optional rename behavior, results, and troubleshooting.
How synchronization protects the policy
Protect keeps the JSON Schema and native SharePoint validation aligned in both directions:
- Unsupported or only partially translatable schemas are rejected before save.
- Cross-column relationships stay in list validation.
- Independent value rules use list validation while the complete formula fits.
- If SharePoint's 1,024-character list-formula limit is exceeded, all independent value rules move together to column validation; they are never split into a weaker approximation.
- If the relationship formula alone exceeds the SharePoint limit, saving stops.
- Fill properties verifies the saved SharePoint formulas before it runs. If somebody changes or weakens them, Fill properties stops and asks an owner to save the policy again.
This makes the library policy the single rule set for both assisted metadata entry and ordinary SharePoint edits.
Supported rules
| Policy requirement | JSON Schema setting |
|---|---|
| Require a value | Add the internal name to top-level required. |
| Allow one exact value | const |
| Allow a controlled set of values | enum |
| Set minimum, maximum, or exact text length | minLength and maxLength |
| Require supported fixed text, digits, prefixes, suffixes, or character formats | A complete anchored pattern beginning with ^ and ending with $ |
| Copy or split a source value for Fill properties | Named captures in pattern |
| Accept alternative complete naming layouts | A supported top-level anyOf for the same required, writable source column |
The editor rejects allOf, oneOf, nested anyOf, incomplete patterns, and other expressions that SharePoint cannot reproduce exactly. Prefer const or enum over regex when the allowed values are known.
Operational limits
- Policies are configured per library.
- Native validation applies when an item is written; it does not retroactively repair existing data.
- Fill properties runs only for the files a user selects.
- Existing valid or invalid files are not scanned on a schedule.
- All Autofill destinations must also have an equivalent native validation rule.
FileLeafRefcan be an extraction source, but it is not a writable validation destination.- A changed or missing managed formula must be synchronized by opening Manage columns and saving the policy again.
For a save or Fill properties error, record the library, affected columns, policy JSON, and complete message before contacting support.
When the same approved policy is required across many libraries, include its JSON Schema, target columns, sample files, owners, and verification checks in a versioned governance template. Pilot it before wider deployment and keep local exceptions separate from the base standard. See Standardize governance across large workspace estates.
