input-validation
Validate construction data inputs before processing: cost estimates, schedules, BIM data, field reports. Catch errors early with domain-specific rules.
What this skill does
# Input Validation for Construction Data
## Overview
Validate incoming construction data before processing to catch errors early. Domain-specific validation rules for estimates, schedules, BIM exports, and field data.
## Validation Framework
### Core Validator Class
```python
from dataclasses import dataclass, field
from typing import List, Dict, Any, Callable, Optional
from enum import Enum
import re
from datetime import datetime
class ValidationSeverity(Enum):
ERROR = "error" # Must fix, blocks processing
WARNING = "warning" # Should review, allows processing
INFO = "info" # FYI, no action needed
@dataclass
class ValidationIssue:
field: str
message: str
severity: ValidationSeverity
value: Any = None
suggestion: str = None
@dataclass
class ValidationResult:
is_valid: bool
issues: List[ValidationIssue] = field(default_factory=list)
def add_error(self, field: str, message: str, value: Any = None, suggestion: str = None):
self.issues.append(ValidationIssue(field, message, ValidationSeverity.ERROR, value, suggestion))
self.is_valid = False
def add_warning(self, field: str, message: str, value: Any = None, suggestion: str = None):
self.issues.append(ValidationIssue(field, message, ValidationSeverity.WARNING, value, suggestion))
def add_info(self, field: str, message: str, value: Any = None):
self.issues.append(ValidationIssue(field, message, ValidationSeverity.INFO, value))
@property
def errors(self) -> List[ValidationIssue]:
return [i for i in self.issues if i.severity == ValidationSeverity.ERROR]
@property
def warnings(self) -> List[ValidationIssue]:
return [i for i in self.issues if i.severity == ValidationSeverity.WARNING]
def to_report(self) -> str:
lines = ["VALIDATION REPORT", "=" * 50]
lines.append(f"Status: {'PASSED' if self.is_valid else 'FAILED'}")
lines.append(f"Errors: {len(self.errors)}, Warnings: {len(self.warnings)}")
lines.append("")
for issue in self.issues:
icon = "❌" if issue.severity == ValidationSeverity.ERROR else "⚠️" if issue.severity == ValidationSeverity.WARNING else "ℹ️"
lines.append(f"{icon} [{issue.field}] {issue.message}")
if issue.suggestion:
lines.append(f" Suggestion: {issue.suggestion}")
return "\n".join(lines)
```
### Cost Estimate Validation
```python
class CostEstimateValidator:
"""Validate cost estimate inputs."""
# Typical cost ranges per CSI division ($/SF)
TYPICAL_RANGES = {
'03': (15, 45), # Concrete
'04': (8, 25), # Masonry
'05': (12, 35), # Metals
'06': (5, 20), # Wood/Plastics
'07': (8, 30), # Thermal/Moisture
'08': (15, 50), # Openings
'09': (10, 40), # Finishes
'22': (8, 25), # Plumbing
'23': (12, 40), # HVAC
'26': (10, 35), # Electrical
}
def validate(self, estimate_data: Dict[str, Any]) -> ValidationResult:
result = ValidationResult(is_valid=True)
# Required fields
self._validate_required_fields(estimate_data, result)
# Line item validation
if 'line_items' in estimate_data:
self._validate_line_items(estimate_data['line_items'], result)
# Total validation
self._validate_totals(estimate_data, result)
# Cost range validation
if 'gross_area' in estimate_data:
self._validate_cost_ranges(estimate_data, result)
return result
def _validate_required_fields(self, data: dict, result: ValidationResult):
required = ['project_name', 'estimate_date', 'line_items', 'total']
for field in required:
if field not in data or data[field] is None:
result.add_error(field, f"Required field '{field}' is missing")
def _validate_line_items(self, items: list, result: ValidationResult):
for i, item in enumerate(items):
# Check for negative values
if item.get('quantity', 0) < 0:
result.add_error(f"line_items[{i}].quantity", "Quantity cannot be negative", item.get('quantity'))
if item.get('unit_cost', 0) < 0:
result.add_error(f"line_items[{i}].unit_cost", "Unit cost cannot be negative", item.get('unit_cost'))
# Check for missing descriptions
if not item.get('description'):
result.add_warning(f"line_items[{i}].description", "Line item missing description")
# Check for valid CSI code
if item.get('csi_code'):
if not re.match(r'^\d{2}\s?\d{2}\s?\d{2}$', item['csi_code']):
result.add_warning(f"line_items[{i}].csi_code", f"Invalid CSI code format: {item['csi_code']}", suggestion="Use format: XX XX XX")
# Check for zero amounts
amount = item.get('quantity', 0) * item.get('unit_cost', 0)
if amount == 0:
result.add_warning(f"line_items[{i}]", "Line item has zero amount")
def _validate_totals(self, data: dict, result: ValidationResult):
if 'line_items' not in data or 'total' not in data:
return
calculated = sum(
item.get('quantity', 0) * item.get('unit_cost', 0)
for item in data['line_items']
)
declared = data['total']
variance = abs(calculated - declared)
if variance > 0.01:
result.add_error("total", f"Total mismatch: calculated {calculated:.2f}, declared {declared:.2f}", variance)
def _validate_cost_ranges(self, data: dict, result: ValidationResult):
gross_area = data['gross_area']
for item in data.get('line_items', []):
csi_div = item.get('csi_code', '')[:2]
if csi_div in self.TYPICAL_RANGES:
amount = item.get('quantity', 0) * item.get('unit_cost', 0)
cost_per_sf = amount / gross_area if gross_area > 0 else 0
low, high = self.TYPICAL_RANGES[csi_div]
if cost_per_sf < low * 0.5 or cost_per_sf > high * 2:
result.add_warning(
f"line_items[{item.get('description', 'Unknown')}]",
f"Cost ${cost_per_sf:.2f}/SF outside typical range ${low}-${high}/SF for Division {csi_div}",
cost_per_sf,
"Review unit costs and quantities"
)
```
### Schedule Validation
```python
class ScheduleValidator:
"""Validate schedule/planning inputs."""
def validate(self, schedule_data: Dict[str, Any]) -> ValidationResult:
result = ValidationResult(is_valid=True)
# Required fields
self._validate_required_fields(schedule_data, result)
# Task validation
if 'tasks' in schedule_data:
self._validate_tasks(schedule_data['tasks'], result)
self._validate_dependencies(schedule_data['tasks'], result)
self._validate_resources(schedule_data['tasks'], result)
return result
def _validate_required_fields(self, data: dict, result: ValidationResult):
required = ['project_name', 'start_date', 'tasks']
for field in required:
if field not in data:
result.add_error(field, f"Required field '{field}' is missing")
def _validate_tasks(self, tasks: list, result: ValidationResult):
task_ids = set()
for i, task in enumerate(tasks):
# Check for duplicate IDs
task_id = task.get('id')
if task_id in task_ids:
result.add_error(f"tasks[{i}].id", f"Duplicate task ID: {task_id}")
task_ids.add(task_id)
# Check dates
start = task.get('start_date')
end = task.get('end_date')
if start and end:
try:
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.