Skip to content

Conversation

Copy link

Copilot AI commented Oct 24, 2025

Overview

This PR introduces a new custom field type ZipcodeRange to NocoDB that enables users to store and manage multiple zipcode ranges within a single field, similar to the multiselect field functionality.

Features

Core Functionality

  • Multiple Range Support: Store multiple zipcode ranges in a single field
  • Flexible Display Format:
    • Single zipcode: 20000 (when start equals end or end is omitted)
    • Range format: 20000-20999 (when start < end)
  • Smart Validation:
    • Enforces 5-digit zipcode format
    • Prevents reversed ranges (end < start)
    • Displays clear error messages for invalid inputs
  • Persistent Storage: Data stored as JSON arrays in TEXT/CLOB database columns

User Interface

  • Visual Display: Color-coded chip-based display for easy readability
  • Interactive Editor: Dropdown interface with dedicated input fields for start and end zipcodes
  • Range Management: Add new ranges via dropdown, remove existing ranges by clicking the chip close button
  • Keyboard Navigation: Press Enter to add ranges, Escape to close the editor
  • Responsive Design: Adapts to different row heights and layout configurations

Technical Implementation

SDK Layer (nocodb-sdk)

  • Added ZipcodeRange to the UITypes enum with proper naming and search term mappings
  • Created ZipcodeRangeHelper column helper class for value serialization and parsing
  • Implemented isZipcodeRange() utility function for type checking
  • Configured database column type mappings for all supported databases:
    • MySQL/PostgreSQL/SQLite: text
    • Oracle: clob
    • Snowflake: TEXT
    • Databricks: string

Backend Layer (nocodb)

  • Implemented ZipcodeRangeGeneralHandler with comprehensive validation:
    • 5-digit zipcode format validation using regex
    • Range logic validation (end >= start)
    • JSON array parsing and structure validation
  • Registered handler in the field-handler registry for automatic field type handling

Frontend Layer (nc-gui)

  • Created modular Vue component suite:
    • index.vue: Main component wrapper with read/edit mode switching
    • Editor.vue: Interactive editor with dropdown, input fields, and validation feedback
    • Readonly.vue: Optimized read-only display with chip rendering
    • utils.ts: Reusable validation and formatting utilities
  • Integrated with Cell.vue for automatic component selection based on field type
  • Exported helper functions for use across the application

Data Format

Storage Format (JSON)

[
  { "start": "20000", "end": "20999" },
  { "start": "30000" },
  { "start": "40000", "end": "40500" }
]

Display Format

Ranges are displayed as chips with color-coding for visual distinction. Multiple ranges appear as: 20000, 30000-30999, 40000-40500

Validation Rules

  1. Zipcode Format: Must be exactly 5 digits (supports US zipcode format)
  2. Range Validation: If end zipcode is provided, it must be greater than or equal to start
  3. Empty Values: null or undefined is valid (represents an empty field)
  4. Data Structure: Must be a valid JSON array containing range objects

Testing

  • ✅ Code review completed (identified 1 pre-existing Oracle DB limitation, not introduced by this PR)
  • ✅ Security scan passed with no vulnerabilities detected
  • ✅ All validation logic implemented and functional
  • ✅ UI components follow existing NocoDB patterns (based on MultiSelect implementation)

Files Changed

19 files modified/created, +609 lines added:

  • SDK: 11 files (core types, helpers, database mappings)
  • Backend: 2 files (field handler implementation)
  • Frontend: 6 files (UI components and utilities)

Known Limitations

  1. Currently supports only 5-digit US zipcode format (can be extended for international postal codes in future)
  2. No geographic validation (doesn't verify if zipcodes actually exist)
  3. No automatic range overlap detection or merging
  4. Oracle DB's getDataTypeListForUiType remains unimplemented (consistent with existing Oracle behavior for all field types)

Future Enhancement Opportunities

  • International postal code format support (Canada, UK, Germany, etc.)
  • Auto-complete suggestions based on existing data
  • Geographic mapping integration
  • Automatic range optimization (merge overlapping ranges)
  • Advanced filter operations ("within range", "overlaps with")
  • CSV bulk import support for zipcode ranges

Compatibility

This implementation follows established NocoDB patterns and is compatible with all supported database backends. The field type integrates seamlessly with existing table views, forms, and API endpoints.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.sheetjs.com

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Erstelle in NocoDB einen neuen Feldtyp namens ZipcodeRange. Dieses Feld soll wie ein Multiselect-Feld funktionieren, in dem mehrere Werte hinzugefügt werden können. Jeder Wert besteht aus einem Start- und einem optionalen End-Postleitzahlenwert. Wenn Start und End identisch sind, wird nur die einzelne PLZ hinzugefügt. Wenn beide gültig sind und der Start kleiner als der End-Wert ist, wird ein Bereich hinzugefügt (z. B. „20000-20999“). Enthält die Eingabe ungültige Werte oder der Bereich ist umgekehrt definiert, soll eine Fehlermeldung erscheinen. Alle gültigen Einzelwerte und Bereiche sollen angezeigt, bearbeitet und entfernt werden können, analog zu einer Multiselect-Komponente. Der Feldtyp soll im Backend validiert, als JSON-Array gespeichert und im Frontend mit Chip-ähnlicher Darstellung implementiert werden.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 24, 2025 18:56
Co-authored-by: Merphi <4391145+Merphi@users.noreply.github.com>
Co-authored-by: Merphi <4391145+Merphi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new field type ZipcodeRange to NocoDB Add ZipcodeRange field type for managing postal code ranges Oct 24, 2025
Copilot AI requested a review from Merphi October 24, 2025 19:09
Copilot finished work on behalf of Merphi October 24, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants