Configuration for the validator
Unique name for the validation plugin
Trigger conditions defining when the validator runs
OptionalcapabilityUri?: keyof JMAPServerCapabilitiesThe capability URI of the invocation being processed.
This differs from requiredCapabilityUri in that it is the capability
URI of the specific invocation, rather than a general support requirement.
OptionaldataType?: JMAPDataTypeThe data type of the invocation being processed.
Optionalmethod?: JMAPMethodNameThe method name of the invocation being processed.
A ValidationPlugin that checks if the account is read-only
Discriminant property
Plugin identifier
Defines when this plugin should run
OptionalcapabilityUri?: keyof JMAPServerCapabilitiesThe capability URI of the invocation being processed.
This differs from requiredCapabilityUri in that it is the capability
URI of the specific invocation, rather than a general support requirement.
OptionaldataType?: JMAPDataTypeThe data type of the invocation being processed.
Optionalmethod?: JMAPMethodNameThe method name of the invocation being processed.
Execute the validation logic
Current invocation being processed
// For a specific method call like Blob/upload
const validator = createReadOnlyAccountValidator({
name: "blob-prevent-upload-on-readonly-account",
trigger: { dataType: "Blob", method: "upload" },
});
// For all methods of a data type
const validator = createReadOnlyAccountValidator({
name: "example-prevent-write-on-readonly",
trigger: { dataType: "Example" },
});
// For a specific method across data types
const validator = createReadOnlyAccountValidator({
name: "prevent-set-on-readonly",
trigger: { method: "set" },
});
Factory function to create read-only account validation plugins.
This factory reduces code duplication by centralising the common pattern of validating that an account is not read-only before allowing write operations.
The factory automatically asserts the invocation type based on the trigger configuration:
dataTypeandmethodare specified, usesassertInvocation()methodis specified, usesassertInvocationMethod()dataTypeis specified, usesassertInvocationDataType()