cableSection static method

String? cableSection(
  1. String? value
)

Validates cable section (common values: 1.5, 2.5, 4, 6, 10, 16, etc.)

Implementation

static String? cableSection(String? value) {
  if (value == null || value.isEmpty) {
    return 'Ingresa la sección del cable';
  }

  final section = double.tryParse(value);
  if (section == null || section < 1.5) {
    return 'La sección mínima es 1.5 mm²';
  }

  // Common sections: 1.5, 2.5, 4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185, 240
  const validSections = [
    1.5,
    2.5,
    4.0,
    6.0,
    10.0,
    16.0,
    25.0,
    35.0,
    50.0,
    70.0,
    95.0,
    120.0,
    150.0,
    185.0,
    240.0,
  ];

  if (!validSections.contains(section)) {
    return 'Sección no estándar. Valores comunes: 1.5, 2.5, 4, 6, 10, 16, 25, etc.';
  }

  return null;
}