Use a Named Rule

XML Forms Guide

Version
R2024.1.1
Use a Named Rule

Named rules are predefined validations that you can use without defining them yourself.

To use a named rule validation, include the following elements:

  • a <ValidationRule> tag where Type=the name of the rule
  • a ValidationFailureMessage parameter

The ValidationFailureMessage parameter provides the error message to be displayed if the form data doesn’t satisfy the rule. You can provide a literal string, or a variable that can be localized.

For example:

Copy
<ValidationRule Event="OnSubmit" 
    Type="MustHaveExactlyOnePrimaryResidenceRule">
    <Parameter Name="ValidationFailureMessage">
        You cannot designate multiple addresses as your 
        primary residence.
    </Parameter>
</ValidationRule>
Available named rules
Rule Name Description
ElectronicStatementAcknowledgementRule Ensures that the policy acknowledgement checkbox is selected when the user submits the form.
EmergencyContactMustHaveRelationshipTypeRule Ensures the following:
  • That the employee's emergency contacts are configured with a relationship type.
  • That a first and last name are entered for the emergency contact.
EmergencyContactValidationRule Ensures that the First Name, Last Name, and Phone Number fields in the Emergency Contacts section of forms are filled out. The rule only runs if at least one setting in the Emergency Contacts section is filled out, so that users can still submit the form without adding any emergency contact information.
EmployeeLoginIdMustBeUniqueRule Ensures that the employee's user name is unique in the application.
EmployeeNumberMustBeUniqueRule Ensures that the employee's employee number is unique in the application.
EmployeePhoneNumberValidationRule Ensures that the employee's phone numbers are in a valid format.
EmployeeRateAndSalaryGreaterThanJobPayGradeRule Ensures that the employee's pay rate is greater than the minimum value configured for the pay grade associated with the employee's job.
EmployeeRateGreaterThanMinimumWageRule Ensures that the employee's pay rate is greater than the minimum wage value configured for the geographic location (province, territory, state, or specific city) based on the employee's work location.
EmployeeZipCodeValidationRule Ensures that the employee's ZIP Code or postal code is in a valid format.
MustHaveExactlyOnePrimaryResidenceRule Ensures that the employee has one and only one address marked as the primary residence.
OnlyOneEffectiveStartPrimaryResidenceRule Ensures that the employee has one and only one primary residence address with a specified start date. If two or more primary address records are defined with the same effective start date, the form displays an error.
SocialSecurityNumberDuplicateRule If the employee’s National ID Number (for example, SSN or SIN) has changed, verifies that the new number isn’t a duplicate of an existing number.
SocialSecurityNumberExistRule Ensures that the employee's SSN or SIN was previously recorded on an employee record. If the number isn’t associated with a terminated employee, because it doesn’t exist on any employee records or it’s associated with an employee that hasn’t been terminated, the application displays a warning message.
SocialSecurityNumberValidationRule

Ensures that the employee's SSN or SIN is in a valid format.

This rule can be associated with the 'PreventRehireFromNewHireForm' parameter, which can be configured with a 'True' or 'False' value. When the parameter is configured as 'True', the application displays an error message when the form is submitted for an employee whose SSN or SIN already exists in the application.

In addition, the rule requires an additional line to invoke the rule during the pre-save process:

<PreSaveProcess Type="DefaultNewHireXMLPreSaveProcess" PreventRehireFromNewHireForm="True" />

For more information, see the example below.

TelecommuterPercentageValidationRule Validates the data that is entered into the Telecommuter % field. If a value outside 0-100 is entered, Dayforce displays an error message. Also, if a value is submitted in the Telecommuter % field for someone in a non-US paygroup, Dayforce displays a warning message but the form can still be processed.
WorkAssignmentRateChangeAgainstPayGradeRule Ensures that if Restrict Out Of Grade is selected for the pay grade an employee belongs to, their job or alternate rate cannot be saved if it’s outside the minimum and maximum range.

Example: Using Named Rules

To configure a form that includes named rules, define the rules after the <DataClass> tag and before the <FormHeader>:

Copy
<WF_DynamicForm>
   <DataClass>Employee</DataClass>
    <ValidationRule Type="EmployeeLoginIdMustBeUniqueRule" 
        Event="OnSubmit" />
    <ValidationRule Type="EmployeeNumberMustBeUniqueRule" 
        Event="OnSubmit" />
    <ValidationRule Type="EmployeePhoneNumberValidationRule" 
        Event="OnSubmit" />
    <ValidationRule Type="SocialSecurityNumberDuplicateRule" 
        Event="OnSubmit">
        <Parameter Name="PreventRehireFromNewHireForm">
        True
        </Parameter>
    </ValidationRule>
    <ValidationRule Type="SocialSecurityNumberAndExpiryDateValidationRule" Event="OnSubmit" />
    <ValidationRule Type="CountyRequiredForPrimaryAddressRule" Event="OnSubmit" />
    <ValidationRule Type="EmployeeRateIsRequired" Event="OnSubmit" />
    <PreSaveProcess Type="DefaultNewHireXMLPreSaveProcess" PreventRehireFromNewHireForm="True" />
    ...
</WF_DynamicForm>