PadCodedocs

Text field rules

The rules a text field in your app can check, with the keyboard each one opens, and how PadCode's own fields check names, numbers and addresses, and how long each can be.

Text can be checked in two places: in the text fields of the app you build, so the people using it know when they've typed something that doesn't fit, and in PadCode's own fields, so a name, a number or an address you type is right before your app runs.

#Check what people type in your app

A Text Field or a Password Field can say what its text must look like: an email, a phone number, a number, a web address, or a pattern of your own. The field opens the keyboard for it, and when what's typed doesn't fit, your app says why, in red, under the field.

A Text Field's Style tab with its Validation section: Must be is set to Email, and Message is empty.
  1. Select the Text Field or Password Field.
  2. In the Inspector's Style tab, find the Validation section.
  3. Pick a rule in Must be.
  4. Optional: type your own Message. Empty uses the one in the table below.

To stop checking, set Must be back to Anything.

Must beWhat it acceptsKeyboard it opensWhat it says when the text doesn't fit
AnythingAny text. Nothing is checked.The field's usual keyboard
EmailAn email address, like name@example.com.The email keyboard, with @ and .Use an email address, like name@example.com.
Phone numberDigits, spaces, + ( ) and -, at least five of them, like +1 (555) 010-2030.The phone keypadUse a phone number: digits, spaces, + ( ) and -.
NumberA number, like 12, -4 or 3.5. A comma works for the decimal point too, like 3,5.The number keys, with a decimal pointUse a number, like 12 or 3.5.
Whole numberA number without a decimal point, like 12 or -4.The number keysUse a whole number, like 12.
Web addressAn address that starts with https://, like https://apple.com.The web address keyboardUse a web address that starts with https://.
Custom patternText that matches your Pattern, from start to end.The usual keyboardThat doesn't match the pattern.

The email, phone and web address keyboards also offer the iPad's autofill for them. Every rule except Custom pattern turns autocorrect and automatic capitals off, so the iPad doesn't change what people type.

#Custom pattern

Pattern is a regular expression the whole text must match. For example, [A-Z]{2}[0-9]{4} accepts two capital letters and four digits, like AB1234.

If PadCode can't read the pattern, it says so under it: "That pattern isn't a regular expression. Check its brackets and backslashes." It's also an error in Issues, so your app won't preview until it's fixed.

#Good to know

  • An empty field is fine. The message only shows once something is typed. Validation doesn't make a field required.
  • Spaces at the start or end don't count, except with Custom pattern, which checks the text exactly as typed.
  • It doesn't stop anything. What's typed still goes into the field's variable, and your steps still run. If a step needs the text to be right, check it first with an If: for example, number(age) != null is true only when age holds a number.
  • Your own keyboard wins. If the field itself has a Keyboard Type modifier, it keeps that keyboard instead of the rule's.
  • The message is your app's. It uses your app's look: small red text under the field. A Message can be up to 200 characters.
A text field in Preview with maya@ typed in, and under it: Use an email address, like name@example.com.

#How PadCode's own fields check what you type

Many of PadCode's fields know what they want. They open the right keyboard, and when what you type doesn't fit, the field gets a red edge and says why under it. An empty field always passes: whether a setting is needed is checked in Issues.

Open Link's Url with apple.com typed in, outlined in red: Use a web address (https://), or a mailto: or tel: link.
The field wantsWhereWhat it says
A name formulas can useVariable names, secret names, color names in Assets, and the field names in Call API's BodyStart with a letter, then use letters, numbers or _, like totalCost.
A numberThe Inspector's number boxes, like sizes and padding, and number settings in stepsUse a number, like 12 or 3.5.
A whole numberMax lines, Pick Photos' Limit, and Whole Number variablesUse a whole number, like 12.
A web address (https://)Call API's Url, a Web Image's or Web Page's Url, a Video Player's Player, and Web Address variablesUse a web address that starts with https://.
A linkOpen Link's Url, and a Web Link's DestinationUse a web address (https://), or a mailto: or tel: link.
An email addressWrite Email's ToUse an email address, like name@example.com.
A language codeSpeak Text's LanguageUse a language code, like en or en-US.
A file nameSave File's NameLeave out / \ : * ? " < > and |.

Only text you type is checked here. A setting you link to a variable or a formula with ⚡︎ is checked when your app runs.

#Names

Formulas read your variables, colors and fields by name, so a name has to start with a letter (or _), then use only letters, numbers and _. totalCost and user_name work; total cost, 2nd and first-name don't.

  • Variables. When you leave the name field, PadCode keeps only the characters a name can have, so first name becomes firstname. A name that ends up empty, or that another variable already has, goes back to what it was. Renaming a variable renames it everywhere your app uses it.
  • Colors in Assets. A name that doesn't fit isn't used: the old name comes back.
  • Secrets. Save to Keychain stays grayed out until the secret has a name and a value.

#How long each field can be

Every field in PadCode has a most it takes, so a name fits the row, card or tab that shows it, and nothing pasted in slows the editor down. Typing stops at the limit, and pasted text is cut to fit.

Kind of fieldUp toFor example
Names40 charactersAn app's name, a screen's title, a view's name in Layers, a saved component's name, a variable, a reusable action, an image or color in Assets, a secret's name
Descriptions200 charactersAn app's description, what a saved component is for, a permission's reason, a text field's Validation Message
Searches100 charactersThe search fields in the Library, Add Action, Add Modifier, Choose an Icon and the typeface picker, and a Map's Place
Numbers20 charactersThe Inspector's number boxes
Text2,000 charactersEverything else your app shows or sends: a title, a starting value, a step's text or address, a formula
Secrets and AI messages4,000 charactersA secret's value (API keys and tokens can be long), and a message to the AI Agent

An app's name and description also can't be blank: Create, Add to My Apps and Save stay grayed out until both are filled in.

#See also