In the UX Builder on the UX Controls page open the 'Data Controls' menu. Click on the [TextBox] option to add a textbox control to the component. Give the textbox control the name and label 'zip'.
Highlight the textbox control. In the properties list on the right click on the ... button next to the 'Validation rules' property in the Field Properties section.
Check the 'Enable rules' checkbox.
In the 'Text Format' section check the 'Allow digits' checkbox. Click OK.
if(data.length !=5) return 'invalid zip code';
In the Data Controls menu click on the [TextBox] option again to add a second textbox to your component. The name and label doesn't matter.
Run the component in Live Preview. Enter a number that is not 5 digits long into the zip textbox, then click on the second textbox. The error message you defined should appear.
Now enter a 5 digit zip code into the textbox and click on the second textbox. The error message should go away.