Question
· Nov 21

RecordMap Data Validation

I am trying to add some validation to an existing Record Map, because recently we had some wrong data get consumed into the System and is causing all kinds of havoc.

Using the AI on the Developer community it suggested that I use PATTERN within the Datatype Parameters to force some validation on some fields. I have never used PATTERN before...

When I go to generate the updated Record Map, I am getting the following...

By the screenshots is my logic not correct?

Product version: IRIS 2024.2
$ZV: HealthShare Provider Directory 2024.2.0 Build: 1009 [HealthShare Modules: Core:28.0 + Provider Directory:28.0] - IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2024.1 (Build 267_2_24113U) Wed Jul 2 2025 16:36:55 EDT [Core:28.0|Provider Directory:28
Discussion (4)4
Log in or sign up to continue

Adding validation using the PATTERN parameter in Record Maps involves ensuring that a specific structure or format for data values is enforced during processing. This method leverages ObjectScript patterns, which are highly versatile for data validation.

Using PATTERN for Validation in Record Maps

You can specify a PATTERN within the Datatype Parameters of a field in your Record Map to validate incoming data. For example:

Property SSN As %String(PATTERN = "3N1""-""2N1""-""4N") [ Required ];

This example validates that an SSN (Social Security Number) follows the format NNN-NN-NNNN, where N represents numeric digits. Literal characters, such as dashes, need to be specified with doubled quotes within the pattern string [1][2].

Verifying Validation Logic

If the generated Record Map doesn't correctly validate your field values or gives unexpected behavior, ensure the following:
1. The PATTERN parameter syntax is correct and enforces the intended format.
2. The expected input strictly matches the required pattern, as validation checks restrict deviations [2][1].
3. Validation errors (e.g., a mismatch with PATTERN or exceeding MAXLEN constraints) should appear during processing and can be assessed via RecordMap error handling mechanisms [1][3].

Troubleshooting Specific Errors

If you're encountering issues with the syntax in your Record Map, errors like data type validation failing due to mismatched formats or incorrect property type definitions such as %Date, check:
1. Whether the datatype parameter aligns with the input value format.
2. Use ##class(%String).IsValid(value) (or similar validation methods) to ensure the value adheres to its type specification and pattern [4][2][1].

If validation for Record Maps continues to fail even after following these corrections, there might be deeper issues in the mapping, the incoming dataset format, or the additional fields. In this scenario, debug the associated fields for compliance with specified parameters [2][1].

Sources:

I'm afraid it's not correct, for example the first item:

For ResearcherId the parretn 1N means "One Number", EXACTLY one number

I think the correct pattern should be .N, this means any number of Number (digits).

Supposing ResearcherId  is  mandatory and my contains only numbers (at least one), the the pattern would be 1.N

Last name would be 1.A, that is at least one low/upper case character

The error you are seeing is a compile error, its not a run time error so the DC AI Bot isnt telling the correct answer.  The field in the RecordMap UI is a bit wonky.  If you hover over the label you get a tooltip which indicates you need to separate the parameter values by ;

So something like this works

MAXLEN=80;PATTERN=14N

which gets stored in the RecordMap definition class as

  <Field name="NPI" required="0" ignored="0" datatype="%String" index="1" params="MAXLEN=80;PATTERN=14N" sqlColumn="2" repeating="0">
  </Field>
and the generated RecordMap class now has

Property NPI As %String(MAXLEN = 80, PATTERN = "14N") [ SqlColumnNumber = 2 ];

so 

1. parameters should be separated by ;

2. for pattern you do not need to surround the pattern value by "s

3. If something like ResearchId is actually a pure numeric and number it might be better defined as %Integer

4. For something like FirstName you might want PATTERN=1.A  which means 1 to N alpha characters