XF 2.2 How to use the "Validator" option on Custom User field

carino

Member
Greetings all,

I have a discussion forum up and running and have created some custom user fields. Among the options for the user field is to value match the entry. One is called "validator". If I select that radio button, a field appears that I have a question about.

1616608485231.webp

How does this work? Is this a space to ask the user a question with only one correct answer? For example, ask what color is the sky and then have a correct answer? I tried that and get an error message.

What I am trying to do is this ...
  • Ask user to enter the number of their street address
  • Validate the user's entry against a list of valid street numbers for our community
I understand that I can select the radio button for number and then enter a min / max value ... but that gives me a range of valid entries, not a list of valid entries.

Outside of custom programming, what are my options?

Thanks,

Steve
 
The validator match requirement lets you specify a PHP validator class to use. The built-in validators are XF:Email, XF:Facebook, XF:Gravatar, XF:Twitter, XF:Url, and XF:Username, or you could implement your own by subclassing \XF\Validator\AbstractValidator in an add-on.

If the number option doesn't work for your use-case, and there is no suitable regular expression, then it would likely be necessary to use a PHP callback or custom validator.
 
Back
Top Bottom