Hi,
For this scenario, I would suggest using a Function Data Action instead of trying to handle all the validation directly inside Architect.
Since the API can return many different date formats, Architect expressions can become hard to maintain. A function would let you validate the raw value, reject unsupported formats, and return only a normalized date back to the flow.
For example, you could send the raw date value to the function and only accept formats like:
Nov 12,25
Nov 12,2025
[Nov 17, 2025]
Anything with a range, missing day, or month/year only would return NOT_SET.
Example Function Data:
JavaScript
// index.js
exports.handler = async (event) => {
const rawDate = event.rawDate || "";
const normalizedDate = normalizeDate(rawDate);
return {
originalValue: rawDate,
isValid: normalizedDate !== "NOT_SET",
normalizedDate: normalizedDate
};
};
function normalizeDate(value) {
if (!value || typeof value !== "string") {
return "NOT_SET";
}
let dateText = value.trim();
// Reject ranges like "Nov 17, 2025 - Dec 17, 2025"
if (dateText.includes("-")) {
return "NOT_SET";
}
// Handle optional brackets
const startsWithBracket = dateText.startsWith("[");
const endsWithBracket = dateText.endsWith("]");
if (startsWithBracket !== endsWithBracket) {
return "NOT_SET";
}
if (startsWithBracket && endsWithBracket) {
dateText = dateText.substring(1, dateText.length - 1).trim();
}
// Accept: Nov 12,25 or Nov 12,2025 or Nov 12, 2025
const regex = /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+([1-9]|[12][0-9]|3[01]),\s*(\d{2}|\d{4})$/i;
const match = dateText.match(regex);
if (!match) {
return "NOT_SET";
}
const monthMap = {
jan: 1,
feb: 2,
mar: 3,
apr: 4,
may: 5,
jun: 6,
jul: 7,
aug: 8,
sep: 9,
oct: 10,
nov: 11,
dec: 12
};
const month = monthMap[match[1].toLowerCase()];
const day = parseInt(match[2], 10);
let year = parseInt(match[3], 10);
if (year < 100) {
year = 2000 + year;
}
// Validate real calendar date
const testDate = new Date(Date.UTC(year, month - 1, day));
if (
testDate.getUTCFullYear() !== year ||
testDate.getUTCMonth() + 1 !== month ||
testDate.getUTCDate() !== day
) {
return "NOT_SET";
}
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
}
Example input:
JSON
{
"rawDate": "Nov 12,25"
}
Example output:
JSON
{
"originalValue": "Nov 12,25",
"isValid": true,
"normalizedDate": "2025-11-12"
}
Then in Architect, you only need to check the function response. If normalizedDate is NOT_SET, skip it or use your fallback logic. If it returns a valid value like 2025-11-12, you can convert/play that date back to the customer.
If this is running inside a loop, this approach will keep the flow much cleaner than trying to build all the string validation directly in Architect.
------------------------------
Arthur Pereira Reinoldes
------------------------------