Data Validator

Overview

This Snap provides the the functionality to validate incoming data against a set of defined constraints. Available constraints are:
  • Pattern
  • Minimum
  • Maximum
  • MinLength
  • MaxLength
  • Required
  • Type

An example of a pattern can be seen in the following image:



The pattern constraint in the screenshot above validates all incoming documents and their attributes a.c.b against the regular expression ^abc, expecting that all attribute values of a.c.b start with abc. If they do, the document is routed to the output view; otherwise, the document is routed to the error view.
  • Pattern is a regular expression, defined as a string value.
  • Minimum and Maximum can only be defined for number values. Allowed constraint values are numbers.
  • MinLength and MaxLength can only be defined for string values. Allowed constraint values are integers.
  • Required can be defined for any value and will verify that a value exists. The Constraint value field is ignored for the Required constraint.
  • Type can be defined for any source path. The default is object. Valid type definitions are: string, number, object, array, boolean, date, time, date-time, local-date-time, any.
Note:

The type constraint should be defined last in case there are multiple constraints defined for a source path.

Limitations

The Data Validator Snap displays an error if the required field is set to true and no object is passed from the upstream.

Workaround: To validate null or empty values, you can either set a Minimum length Constraint of 1, or use the regex pattern ^.+$“

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap has exactly one document input view.
Output This Snap has exactly one document output view.
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Data Validator

Example: Data Validator
Constraints Required. Define constraints for one or more fields. If multiple constraints are defined for the same field using the same constraint, only the first definition is considered.
Available options are:
  • Pattern
  • Minimum
  • Maximum
  • MinLength
  • MaxLength
  • Required
  • Type

Default value: N/A

Example:

Source Path Constraint Constraint Value
$numberCol Required True
$numberCol Minimum 1
$numberCol Maximum 5
Validate full JSON path Checkbox Select this property to enable the Snap to verify if all parents in the JSON path exist, and produce an error if all parents do not exist.

Default status: Deselected

Example: When there is only one Constraint Required=true for a Source path=$a.c.b, but an input document is as follows:
{
	"a": {
		"b": {
			"c": "xyz"
		}
	}
}

The Snap does not produce an error if this property is not selected, even if the JSON path $a.c.b has no values unless there is another Constraint Required=true for a Source path=$a.c.

If this property is selected, the Snap produces an error with a reason field. Example, Path not found: $.a.c, Source path: $.a.c.b, Constraint: Required=true.

Default status: Deselected

Standardize error output Checkbox If true, the Snap produces the error document in standard error format (error, reason, original, and stack trace). If false, the error document contains error and original.

Default status: Deselected

Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Validate and Execute

Example: Execute only

Example: