Class CaseRelationValidateFunction
Validates the combined state of source and target case fields within a case relation.
Implements
Inherited Members
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public class CaseRelationValidateFunction : CaseRelationFunction, IDisposable
Remarks
This function runs after CaseRelationBuildFunction has populated the target case fields. It can inspect both source and target values to detect invalid combinations and report issues.
Typical uses:
- Ensure that a target value derived from the source is within allowed limits.
- Verify that the source slot is eligible to create the target relation.
- Cross-case consistency checks that cannot be expressed at the individual case level.
Adding issues: Use AddCaseIssue(string, int) for relation-level messages and AddCaseFieldIssue(string, string, int) to attach an issue to a specific target field. Localised messages can be referenced via AddCaseAttributeIssue(string, params object[]) and AddAttributeIssue(string, string, params object[]).
Return value: Return null to pass validation.
Return false to reject the relation without an explicit message.
The submission is blocked if any issue is present.
Low-Code / No-Code: Simple relation validations can be expressed
through action expressions using CaseRelationValidateAction attributes.
The Validate() entry point invokes registered actions before the script body.
Examples
// Ensure the derived target wage does not exceed the global cap
var cap = GetLookup<decimal>("WageCap", "Max");
if ((decimal)TargetValue["Wage"] > cap)
AddCaseFieldIssue("Wage", $"Derived wage exceeds the allowed cap of {cap}.");
Constructors
View SourceCaseRelationValidateFunction(object)
Initializes a new instance with the function runtime
Declaration
public CaseRelationValidateFunction(object runtime)
Parameters
| Type | Name | Description |
|---|---|---|
| object | runtime | The runtime |
CaseRelationValidateFunction(string)
New function instance without runtime (scripting development)
Declaration
protected CaseRelationValidateFunction(string sourceFileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceFileName | The name of the source file |
Remarks
Use GetSourceFileName(string) in your constructor for the source file name
Methods
View SourceAddAttributeIssue(string, string, params object[])
Add case field issue from attribute
Declaration
public void AddAttributeIssue(string caseFieldName, string attributeName, params object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| string | caseFieldName | Case field name |
| string | attributeName | Attribute name |
| object[] | parameters | Message parameters |
AddCaseAttributeIssue(string, params object[])
Add case issue from attribute
Declaration
public void AddCaseAttributeIssue(string attributeName, params object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| string | attributeName | Attribute name |
| object[] | parameters | Message parameters |
AddCaseFieldIssue(string, string, int)
Add a new case field issue
Declaration
public void AddCaseFieldIssue(string caseFieldName, string message, int number = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | caseFieldName | Name of the case field |
| string | message | The issue message |
| int | number | The issue number |
AddCaseIssue(string, int)
Add a new case issue
Declaration
public void AddCaseIssue(string message, int number = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | The issue message |
| int | number | The issue number |
HasIssues()
Test for issues
Declaration
public bool HasIssues()
Returns
| Type | Description |
|---|---|
| bool |
Validate()
Entry point for the runtime
Declaration
public bool? Validate()
Returns
| Type | Description |
|---|---|
| bool? |
Remarks
Internal usage only, do not call this method