Skip to content

Instantly share code, notes, and snippets.

@tgranqvist
Last active October 17, 2024 13:46
Show Gist options
  • Select an option

  • Save tgranqvist/476dc4748d58c62836a2b50c4d64d019 to your computer and use it in GitHub Desktop.

Select an option

Save tgranqvist/476dc4748d58c62836a2b50c4d64d019 to your computer and use it in GitHub Desktop.
Validation patterns for XLSForm

Validation patterns for XLSForm

This is my collection of validation patterns for XLSForm, mainly used in Kobo. To use in Kobo, click the cog at the question, go to validation criteria, click to manually enter validation logic in XLSForm code and paste the pattern. Contributions welcome!

Phone number

regex(., '\+?\d+$')

Allows any length numeric, no-spaces phone number, possibly starting with "+" for country code.

Finnish personal identity code

regex(., '^(0[1-9]|[12][0-9]|3[01])(0[1-9]|1[0-2])(\d{2})([-+yxwvuabcdefYXWVUABCDEF])(\d{3})([0123456789abcdefhjklmnprstuvwxyABCDEFHJKLMNPRSTUVWXY])$')

Allows any Finnish personal identity code according to the 2023 code reform.

Note on capture groups

The groupings are necessary for the pattern to validate correctly, but could likely be non-capturing groups as the result can't be used in Kobo anywhere. I haven't tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment