The application implements comprehensive validation at both client and server levels to ensure data integrity and consistency with BTC Map requirements.
| Field | Type | Validation Rules |
|---|---|---|
name |
text | Non-empty string |
type |
select | Must be "community" |
url_alias |
text | Non-empty, URL-friendly string |
continent |
select | One of: africa, asia, europe, north-america, oceania, south-america |
icon:square |
text | Non-empty string |
population |
number | Non-negative integer |
population:date |
date | YYYY-MM-DD format |
geo_json |
object | Valid GeoJSON Polygon/MultiPolygon |
| Field | Type | Validation Rules |
|---|---|---|
area_km2 |
number | Non-negative decimal (auto-calculated from GeoJSON) |
organization |
text | Any non-empty string |
language |
text | Any non-empty string |
description |
text | Any non-empty string |
| Field | Type | Validation Rules |
|---|---|---|
contact:website |
url | Valid URL format |
contact:email |
Valid email format | |
contact:phone |
tel | Valid phone number format |
contact:twitter |
url | Valid URL format |
contact:telegram |
url | Valid URL format |
contact:signal |
url | Valid URL format |
contact:whatsapp |
url | Valid URL format |
contact:discord |
url | Valid URL format |
contact:instagram |
url | Valid URL format |
contact:youtube |
url | Valid URL format |
contact:facebook |
url | Valid URL format |
contact:linkedin |
url | Valid URL format |
contact:github |
url | Valid URL format |
contact:matrix |
url | Valid URL format |
contact:geyser |
url | Valid URL format |
contact:eventbrite |
url | Valid URL format |
contact:reddit |
url | Valid URL format |
contact:simplex |
url | Valid URL format |
contact:satlantis |
url | Valid URL format |
contact:rss |
url | Valid URL format |
contact:meetup |
url | Valid URL format |
contact:nostr |
text | Any non-empty string |
tips:lightning_address |
text | Any non-empty string |
- Validates against allowed values if provided
- Ensures non-empty strings
- Used for basic text fields
- Accepts integers, floats, or numeric strings
- Must be >= 0
- Used for
area_km2field
- Accepts integers or integer strings
- Must be >= 0
- Used for
populationfield
- Must match YYYY-MM-DD format
- Uses
datetime.strptimefor validation - Used for
population:datefield
- Uses
urllib.parse.urlparse - Requires valid scheme and netloc
- Used for all contact URL fields
- Regex pattern:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ - Standard email format validation
- Regex pattern:
^\+?1?\d{9,15}$ - Allows optional country code
- 9-15 digits total
- Accepts string or object input
- Validates JSON structure
- Uses Shapely for geometry validation
- Only allows Polygon and MultiPolygon types
- Applies
geojson_rewindfor correct orientation - Returns rewound GeoJSON object
- Case-insensitive matching against allowed list
- Used for select/dropdown fields
- Checks for duplicate keys
- Validates custom key format
- Ensures required fields are present
- Real-time feedback on input
- Type-specific validation (numbers, URLs, emails)
- Visual feedback with Bootstrap validation classes
- JSON syntax validation
- Geometry type checking
- Interactive map preview
- Error highlighting and messages
When a valid GeoJSON is provided:
- Geometry is converted using Shapely
- Projected to Albers Equal Area for accurate measurement
- Area calculated in square meters
- Converted to square kilometers
- Rounded to 2 decimal places
- Automatically set as
area_km2tag
- Client-side validation on form submission
- Server-side validation of all fields
- GeoJSON geometry validation and rewinding
- Area calculation from geometry
- RPC call to backend with validated data
- Field-specific validation based on type
- Special handling for GeoJSON updates
- Automatic area recalculation for geometry changes
- Individual tag updates via RPC
- Validation errors prevent form submission
- Clear error messages displayed to user
- Server errors returned with descriptive messages
- Client provides immediate feedback for invalid input
Users can add custom fields beyond the predefined schema:
- Custom key validation (no duplicates, valid format)
- Value validation based on inferred type
- Full CRUD operations on custom tags
- Removal restrictions for required fields
- All user input is validated on both client and server
- SQL injection prevention through proper data handling
- XSS prevention through template escaping
- Input sanitization for all text fields
- Geometry validation prevents malicious GeoJSON