Problem passing map to function

Problem passing map to function

Sry for the long post. Including all documentation. Zoho is triggering the following error when I try to pass a map to a function, and I can't figure out why:

Error during validation: Error at line : 14, Function specified in criteria has returned null value and it cannot be evaluated

1. My form creates a map of required fields On Validate:

requiredFieldValues = Map();

// Fetch required fields for the form
requiredFields = Fields[form.form_name == "API Protocols" && is_required == true];

for each field in requiredFields
{
    fieldValue = getFieldValue(field.link_name);
    requiredFieldValues.put(field.field_name, fieldValue);
    info "Key: " + field.link_name + ", Value: " + fieldValue;    
}

info "Constructed requiredFieldValues: " + requiredFieldValues;

// Check if the map is empty
if (requiredFieldValues.isEmpty())
{
    alert "No fields to validate.";
    cancel submit;
}

try {
    // Validate required fields - this is line that triggers error
    validationResult = thisapp.validateRequiredFields(requiredFieldValues);

    // Check validation status
    if (validationResult == null || validationResult.get("status") != "success")
    {
        alert "Enter a value for the following required fields: " + validationResult.get("message") ;
        cancel submit;
    }
} catch(e) {
     // Log the error and provide a fallback message
    info "Error during validation: " + e.toString();
    alert "An unexpected error occurred during validation. Please try again.";
    cancel submit;
}

2. The above info lines return the following, which looks like a valid map:
Required fields: api_protocol,eff_date,exp_date
Key: api_protocol, Value: Test
Key: eff_date, Value: 01-01-2025
Key: exp_date, Value: 12-31-2999
Constructed map requiredFieldValues: {"API Protocol":"Test","Eff Date":"01-01-2025","Exp Date":"12-31-2999"}

3. That map is fed into the following function, which takes a map as argument:

map validateRequiredFields(map requiredFieldValues)
{

    // Initialize the response map
    validationResult = Map();
    validationResult.put("status", "success");
    validationResult.put("message", "All required fields are filled");

    // List to track empty fields
    emptyFieldList = List();

    // Iterate over the keys in the map
    for each fieldKey in requiredFieldValues.keys()
    {
        fieldValue = requiredFieldValues.get(fieldKey);
        // Check for null or empty values
        if (fieldValue == null || (fieldValue.isEmpty()))
        {
            emptyFieldList.add(fieldKey);
        }
    }

    // If there are empty fields, update the validation result
    if (emptyFieldList.size() > 0)
    {
        validationResult.put("status", "failure");
        validationResult.put("message", emptyFieldList);
        //validationResult.put("emptyFields", emptyFieldList);
    }

    return validationResult;
}

4. If I test the function by itself with the above map, the function works as expected.

5. When I execute the form, this line fails On Validate:
    validationResult = thisapp.validateRequiredFields(requiredFieldValues);

But if I replace the variable with its actual value (per the info line), it works.
    validationResult = thisapp.validateRequiredFields({"API Protocol":"Test","Eff Date":"01-01-2025","Exp Date":"12-31-2999"});

What am I missing?