""" Validation utilities for model card inputs """ import re def validate_mmcid(mmcid): """ Validate MMCID format: DF-MC-YYYY-NNN Args: mmcid: String to validate Returns: Boolean indicating if format is valid Examples: DF-MC-2025-001 ✓ DF-MC-2024-123 ✓ df-mc-2025-001 ✗ (wrong case) DF-MC-25-001 ✗ (year must be 4 digits) """ if not mmcid: return True # Empty is valid (optional field) pattern = r'^DF-MC-\d{4}-\d{3}$' return bool(re.match(pattern, mmcid)) def validate_controlled_vocab_selection(selections, max_items=3): """ Validate that multi-select doesn't exceed max items Args: selections: List of selected items max_items: Maximum allowed selections (default 3) Returns: Tuple of (is_valid, error_message) """ if not selections: return True, None if len(selections) > max_items: return False, f"Please select no more than {max_items} items" return True, None