· Nov 6, 2023 2m read

IRIS Smart String Package

Hi folks,

I have published a new package on OEX.

In short, it is a string datatype that support various configuration options and flexibility.

Business Case

  1. You have some library classes and other reusable structures that you use across systems.
  2. You have a "multi-tenant" environment where one code base is shared amongst tenants, which each have their own namespaces configured.
    1. Specific rules and business processes are stored in that tenant's namespace.
    2. The core class structures are the same.
    3. Tenants have different data validation requirements and some want data consistency across systems in their organisation.

If you have six tenants and they each have different levels of validation on an identification number (SSN), you want to be able to accommodate each without having to create a subset of classes for each tenant.

Some tenants also want data to be scrubbed to ensure consistency.

Solving the Problem

A String class with the option of compile0time and run-time configurability that can be changed dynamically.

This class offers the following

  1. Set the REGEX parameter value for regular expression validation in the IsValid method.
    1. Set REGEXMODE to "globalref", and IsValid will get a value from a global to use as the regular expression pattern.
      1. e.g. REGEXMODE = "^MyConf(""IDNumberRegex"")" Then set up the pattern in that global and node.
  2. Set the DATACLEANUPSEQUENCE parameter value to be applied during the Normalize method.
    1. The value is a %List of %Lists containing the instructions for $ZSTRIP.
      1. e.g. DATACLEANUPSEQUENCE = "$lb($lb(""<>WC"","""",""""),$lb(""*P"","""",""-""))"
    2. Set DATACLEANUPMODE to "globalref", and Normalize will read the cleanup sequence from the global indicated by the value in DATACLEANUPSEQUENCE. e.g. DATACLEANUPSEQUENCE  = "^MyConf(""LastNameCleanup"")" Then set up the sequence in that global and node.
      1. e.g. "^MyConf(""LastNameCleanup"") = $lb($lb("*PC","","'- "),$lb("<->W","",""))
  3. Set the ADDITIONALVALIDATIONCALL parameter value to a classmethod call to be done during IsValid, after all other validations have passed.
    1. The value has the format of "##class(My.ValidatorClass).MyClassMethod()"
    2. Set ADDITIONALVALIDATIONMODE to "globalref", and IsValid will read the validation method to be used from the global indicated by the value in ADDITIONALVALIDATIONCALL.
      1. e.g. ADDITIONALVALIDATIONCALL= "^MyConf(""LastNameCleanup"")" Then set up the sequence in that global and node.
        1. e.g. "^MyConf(""IDNumberValidator"") = "##class(BaseLib.Validators.ZAID).Validate()"



The GitHub repo contains a full demo of this functionality, and example classes.

Thank you

Discussion (0)1
Log in or sign up to continue