XF 2.2 Validate BB Code before saving a post

Phid

Member
Dear Sir/Madam,

I've been searching but haven't found an answer for the specific question I've, maybe I made the wrong queries... hope anyone can throw me some light or point me into the right direction.

I've created a custom add-on for some custom BB Codes along with some dialogs for helping on the input of the BB Code itself. So far so good, the values are validated on such dialogs and the user can't make a mistake, however, as soon as the BB Code is validated and inserted into the editor the user can change the values of it. My question is how to intercept the BB Codes before inserting the post. I would like to be able to get a list of the BB Codes used and check the options and if is valid, let it go through or stop it and display a message.

An example of the BB Code is as follows:

Code:
[EXCLUDE=6]This is a content with exclude 6[/EXCLUDE]

I would like to validate the option that is passed to this BB Code, and if the user used a non-valid number by manually editing or typing the BB Code, show an error.

Thanks in advance!
 
Are you using the Option match regular expression field to validate the input?
Yes I am, so far I'm validating numbers only which avoids other inputs but I would like to validate if for example the number 6 is a valid one. The values I'm trying to validate against comes from custom options. If on the options I've valid values as 6,7 and 8, I would like to validate the input that it matches those and reject if it doesn't.

This is so far for a custom BB Code, but there is another that would like to validate differently, like not allowing a value lower than x and higher than y.
 
If the validation you need to do isn't possible with regex then it would require custom development.
Thank you, I'm aware of that, I just don't know where exactly to start.
If you could point me out on the right direction I would appreciate it. Like you need to extend xyz and override this method.

For example, I've been able to validate if the user has permission to use the BB Code by extending XFCP_Preparer. My guess is that I could also use it to validate the BB Code, I just haven't figured it out how to obtain the BB Code and its option.
 
Well, I did a regex match by extending the XFCP_Preparer, not sure if that's the correct way but it worked.
I was expecting something built-in that could parse the message and get an array of BB codes used along with the options passed if any.
 
Top Bottom