An engineer wants to verify that a user-entered US ZIP code consists of exactly five consecutive digits before proceeding with address lookup. The assistant should reject inputs like '9021' (too short) or '90210X' (letters present). Which condition approach best enforces this format?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Todd Lammle: 'Imagine you're building a chatbot and this exact situation comes up — use the 'matches regex' operator with the pattern ^\\d{5}$ to enforce exactly five digits with no other characters is your go-to move. The 'matches regex' operator evaluates a full regular-expression pattern against the input. This is a classic Domain 1: Build Conversational Flows concept you'll want locked in before exam day.'
Full explanation below image
Full Explanation
The 'matches regex' operator evaluates a full regular-expression pattern against the input. The pattern ^\\d{5}$ anchors to the start (^) and end ($) of the string and requires exactly five digit characters (\\d{5}), rejecting anything shorter, longer, or containing non-digit characters. The other operators cannot enforce length or character-class constraints simultaneously. The correct answer, "Use the 'matches regex' operator with the pattern ^\\d{5}$ to enforce exactly five digits with no other characters", directly satisfies the scenario because it aligns with watsonx Assistant's design principles and the specific capability being tested. The incorrect options ("Use the 'equals' operator and enumerate all valid five-digit ZIP codes as comma-separated literals", "Use the 'contains' operator to check whether the input contains at least one digit character", "Use the 'starts with' operator to confirm the first character is a numeral") may appear relevant but each misses a key requirement or introduces a step that is either unnecessary or belongs to a different workflow. Mastering the distinction between these approaches is essential for effective watsonx Assistant implementations and is a core focus of the Domain 1: Build Conversational Flows section of the certification exam.