Class CaseValidateFunction
Validates case field values when the user submits the input form.
Implements
Inherited Members
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public class CaseValidateFunction : CaseChangeFunction, IDisposable
Remarks
This function runs after the user confirms the case form. It checks field values for correctness and adds issues for any violations. Validation issues are displayed inline next to the affected field or at the case level.
Typical uses:
- Check that a field value is within an allowed range.
- Ensure date constraints: start must be before end, dates within the payroll period.
- Cross-field validation: two fields that must be consistent with each other.
- Business rules: reject submissions that conflict with existing case values.
Adding issues: Use AddCaseIssue(string) for case-level messages
and AddCaseFieldIssue(string, string) to attach an issue to a specific field.
Issues with localised messages can be added via AddCaseAttributeIssue(string, params object[]) and
AddFieldAttributeIssue(string, string, params object[]) by referencing a lookup-backed ActionIssueAttribute.
Return value: Return null (or omit the return) to pass validation.
Returning false marks the case as invalid without adding an explicit message.
The runtime rejects the submission if any issues are present regardless of the return value.
Low-Code / No-Code: Simple validations can be expressed through
action expressions using CaseValidateAction attributes — no C# scripting required.
The Validate() entry point invokes all registered actions before executing
any inline script body.
Examples
// Ensure a salary value is positive
if (GetValue<decimal>("Salary") <= 0)
AddCaseFieldIssue("Salary", "Salary must be greater than zero.");
// Cross-field: end date must be after start date
if (GetEnd("Contract") <= GetStart("Contract"))
AddCaseFieldIssue("Contract", "End date must be after start date.");
Constructors
View SourceCaseValidateFunction(object)
Initializes a new instance with the function runtime
Declaration
public CaseValidateFunction(object runtime)
Parameters
| Type | Name | Description |
|---|---|---|
| object | runtime | The runtime |
CaseValidateFunction(string)
New function instance without runtime (scripting development)
Declaration
protected CaseValidateFunction(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[])
Adds a case field issue using a localised message from an attribute; alias for AddFieldAttributeIssue(string, string, params object[])
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 | Optional message format 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)
Add a new case field validation issue
Declaration
public void AddCaseFieldIssue(string caseFieldName, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| string | caseFieldName | Name of the case field |
| string | message | The issue message |
AddCaseIssue(string)
Add a new case validation issue
Declaration
public void AddCaseIssue(string message)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | The issue message |
AddFieldAttributeIssue(string, string, params object[])
Add case field issue from attribute
Declaration
public void AddFieldAttributeIssue(string caseFieldName, string attributeName, params object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| string | caseFieldName | Case field name |
| string | attributeName | Attribute name |
| object[] | parameters | Message parameters |
AddInfo(string, object)
Adds or updates a named entry in the form's edit-info attribute
Declaration
public void AddInfo(string name, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The info entry name |
| object | value | The info entry value |
HasIssues()
Test for issues
Declaration
public bool HasIssues()
Returns
| Type | Description |
|---|---|
| bool |
RemoveInfo(string)
Removes a named entry from the form's edit-info attribute
Declaration
public void RemoveInfo(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The info entry name to remove |
Validate()
Entry point for the runtime
Declaration
public bool? Validate()
Returns
| Type | Description |
|---|---|
| bool? |
Remarks
Internal usage only, do not call this method