Validation Rules

Learn how you can implement custom rules to improve the quality and consistency of your data or create new custom business rules.
 

Validation rules let you create rules that check your customer and booking data to make sure they meet specific criteria. For example, you can make specific fields required or meet a specific pattern.

Validation rules are applied to records created or updated from the Nexudus dashboard, the members portal or the API.

You can apply validation rules to three types of records.

  • Customers
  • Bookings
  • Contracts
  • Visitors

To create a validation rule:

  1. If the side menu is not visible, click .

  2. In the side menu, click Settings.

  3. In the Features section, click Validation Rules.  

  4. Click Add Validation Rule.

  5. Complete the Validation Rule details and click Save.

image__74_.png
An example validation rule checking a field is no blank or empty.
 

Validation Rule Formulas

The formula for validation rules has to always return a true or false value. When the returned value is true the validation rule system will allow the record to be created or updated, otherwise the validation error message set in the details of the rule will be shown to the user and the record won't be created or updated.

The following variables are available to be used in the formula:

Variable

Description

user

The currently logged-in user.

user.email

The email address of the currently logged-in user.

record

The record the formula is being evaluated for. This can be a booking or a customer.

The following functions are available in Booking formulas

Name

Description

MinutesToBooking(booking)

Returns the amount of minutes until the booking starts

HasTaggedProduct(booking, tag)

Returns true if the booking has a product with a given tag

HasProduct(booking, productId)

Returns true if the booking a product with a given Id

ProductQuantity(booking, productId)

Returns the quantity of a product included in a booking

IsInRole(user, roleName)

Returns true if the user is part a role

IsInPlan(customer, planName)

Returns true if the customer has an active contract for a plan

IsInPlan(customer, planId)

Returns true if the customer has an active contract for a plan

WasIsInPlan(customer, planId)

Returns true if the customer has or had an active contract for a plan.

HasProduct(customer, productId)

Returns true if the customer has purchased a product (paid or not)

HasPass(customer, passId)

Returns true if the customer has purchase.

UnpaidInvoicesAmount(customer)

Returns the total amount in unpaid invoices

 

 

 

The following functions are available in all formulas:

Name

Description

PI

The value of PI

E

The value of E

Abs

Returns the absolute value of number

BigMul

Produces the full product of two 32-bit numbers.

Ceiling

Returns the smallest integral value that is greater than or equal to the specified decimal number.

Floor

Returns the largest integer less than or equal to the specified decimal number.

Log(x,b)

Returns the logarithm of a specified number in a specified base.

Max(a,b)

Returns the larger of two numbers

Min(a,b)

Returns the smaller of two numbers.

Round(d,decimals)

Rounds a number to a specified number of fractional digits.

Truncate(d)

Calculates the integral part of a specified number.

IsMatch(input,pattern)

Indicates whether the specified regular expression finds a match in the specified input.

ToBoolean

Converts a value to a boolean

ToDateTime

Converts a value to a date

ToDecimal

Converts a value to a decimal number

ToDouble

Converts a value to a double number

ToInt32

Converts a value to a integer

ToInt64

Converts a value to a integer

ToString

Converts a value to a string

 

Example Formulas:

Setting a field as required

The example below checks the TaxIDNumber field (TAX / VAT Number) is present.

image__75_.png
An example validation rule checking a field is no blank or empty.
 
record.TaxIDNumber <> null AND record.TaxIDNumber <> ""

Checking a field value meets a specific value

The example below checks the TaxIDNumber field (TAX / VAT Number) meets a specific regular expression.

image__76_.png
An example validation rule checking a field meets the UK VAT number pattern.
 
IsMatch(record.TaxIDNumber, "GB([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})")

Checking the currently logged in user is a full unrestricted admin.

user.IsAdmin
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.