DynamicForm.Instance.Validator (DynamicForm v0.18.1)

Copy Markdown View Source

Represents a validation rule for a form question using SurveyJS-compatible format.

SurveyJS Validator Types

  • "text" - Text length validation (minLength, maxLength)
  • "numeric" - Numeric range validation (minValue, maxValue)
  • "email" - Email format validation
  • "regex" - Regular expression validation

Examples

# Text length validator
%Validator{type: "text", minLength: 2, maxLength: 100}

# Numeric range validator
%Validator{type: "numeric", minValue: 1, maxValue: 10}

# Email format validator
%Validator{type: "email"}

# Custom error message
%Validator{type: "text", minLength: 5, text: "Must be at least 5 characters"}

Summary

Types

t()

@type t() :: %DynamicForm.Instance.Validator{
  maxLength: integer() | nil,
  maxValue: number() | nil,
  minLength: integer() | nil,
  minValue: number() | nil,
  regex: String.t() | nil,
  text: String.t() | nil,
  type: String.t()
}