Fields

Fields are the fundamental data collection units in the Global PRS system. They define how information is captured, validated, and processed throughout the registration process. This section covers field types, configuration, and best practices.

Field Types

1. Text Fields

  • Single line text
  • Multi-line text
  • Rich text
  • Masked input

2. Numeric Fields

  • Integer
  • Decimal
  • Currency
  • Percentage

3. Selection Fields

  • Dropdown
  • Radio buttons
  • Checkboxes
  • Multi-select

4. Special Fields

  • Date picker
  • Time picker
  • File upload
  • Location picker

Field Configuration

1. Basic Structure

{
  "fieldId": "full_name",
  "type": "text",
  "label": "Full Name",
  "placeholder": "Enter your full name",
  "required": true,
  "validation": {
    "pattern": "^[a-zA-Z ]{2,50}$",
    "message": "Please enter a valid name"
  },
  "display": {
    "condition": "{age} >= 18",
    "order": 1
  }
}

Field Features

1. Validation

  • Required fields
  • Pattern matching
  • Range validation
  • Custom validation
  • Cross-field validation

2. Display Logic

  • Conditional visibility
  • Dynamic options
  • Dependent fields
  • Custom rendering

3. Data Processing

  • Format conversion
  • Value transformation
  • Aggregation
  • Calculation

Field Implementation

1. Text Field

{
  "type": "text",
  "config": {
    "minLength": 2,
    "maxLength": 50,
    "pattern": "[a-zA-Z ]+",
    "transform": "uppercase"
  }
}

2. Select Field

{
  "type": "select",
  "config": {
    "options": [
      {"value": "1", "label": "Option 1"},
      {"value": "2", "label": "Option 2"}
    ],
    "multiple": false,
    "searchable": true
  }
}

3. Date Field

{
  "type": "date",
  "config": {
    "format": "YYYY-MM-DD",
    "min": "{today}",
    "max": "{today+30d}",
    "disabledDays": ["sunday"]
  }
}

Field Validation

1. Built-in Validators

  • Required
  • Email
  • Phone
  • URL
  • Numeric
  • Date

2. Custom Validators

  • Regex patterns
  • Function validators
  • Async validators
  • Cross-field validators

3. Validation Messages

  • Error templates
  • Custom messages
  • Localization
  • Dynamic content

Field Dependencies

1. Value Dependencies

  • Calculated fields
  • Conditional values
  • Lookup fields
  • Aggregations

2. Display Dependencies

  • Visibility rules
  • Enable/disable rules
  • Option filtering
  • Dynamic updates

Best Practices

1. Field Design

  • Clear labels
  • Helpful placeholders
  • Consistent formatting
  • Appropriate defaults
  • Error guidance

2. Validation

  • Progressive validation
  • Clear error messages
  • Helpful suggestions
  • Graceful handling

3. Performance

  • Efficient validation
  • Optimized rendering
  • Minimal dependencies
  • Cache usage

Field States

1. UI States

  • Empty
  • Filled
  • Invalid
  • Disabled
  • Loading

2. Validation States

  • Not validated
  • Valid
  • Invalid
  • Pending
  • Error

Security

1. Input Validation

  • Type checking
  • Range checking
  • Pattern matching
  • Sanitization

2. Access Control

  • Field permissions
  • Value restrictions
  • Audit logging
  • Data protection

Next Steps