From e2222afff180ee77f330ef4325f60d6e85477c01 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Sun, 26 Oct 2025 23:52:47 +0200 Subject: [PATCH] fix(validate-inputs): add logic to skip undefined empty (#311) * fix(validate-inputs): add logic to skip undefined empty * chore: code review comments --- validate-inputs/validators/conventions.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/validate-inputs/validators/conventions.py b/validate-inputs/validators/conventions.py index ced6375..ab19904 100644 --- a/validate-inputs/validators/conventions.py +++ b/validate-inputs/validators/conventions.py @@ -285,6 +285,8 @@ class ConventionBasedValidator(BaseValidator): # Get conventions and overrides from rules conventions = self._rules.get("conventions", {}) overrides = self._rules.get("overrides", {}) + optional_inputs = self._rules.get("optional_inputs", {}) + required_inputs = self.get_required_inputs() # Validate each input for input_name, value in inputs.items(): @@ -292,12 +294,28 @@ class ConventionBasedValidator(BaseValidator): if input_name in overrides and overrides[input_name] is None: continue + # Check if input is defined in the action's rules + is_defined_input = ( + input_name in required_inputs + or input_name in optional_inputs + or input_name in conventions + or input_name in overrides + ) + + # Skip validation for undefined inputs with empty values + # This prevents auto-validation of irrelevant inputs from the + # validate-inputs action's own input list + if not is_defined_input and ( + not value or (isinstance(value, str) and not value.strip()) + ): + continue + # Get validator type from overrides or conventions validator_type = self._get_validator_type(input_name, conventions, overrides) if validator_type: # Check if this is a required input - is_required = input_name in self.get_required_inputs() + is_required = input_name in required_inputs valid &= self._apply_validator( input_name, value, validator_type, is_required=is_required )