jbowens / jBBCode

A lightweight but extensible BBCode parser
http://jbbcode.com
MIT License
164 stars 32 forks source link

Allow function as parameter of setOptionValidator() & setBodyValidator() #60

Open cstdenis opened 9 years ago

cstdenis commented 9 years ago

I need a number validator(for a [size] tag).

I would be very nice to be able to do a simple setOptionValidator('is_numeric');

rather than having to wrap is_numeric() inside a class just to use it in this context

class sizeValidator implements \JBBCode\InputValidator
{
    public function validate($input)
    {
        return is_numeric($input)
    }
}

setOptionValidator(new sizeValidator());

Would also allow for anonymous function as argument

setOptionValidator(function($input) { return is_numeric($input) });

Kubo2 commented 9 years ago
-Assigned:
+Assigned: Kubo2

just to not forget about this one

Kubo2 commented 9 years ago

Hey @jbowens, could you please really assign me to this one? I already have an implementation here: #61

Kubo2 commented 8 years ago

@cstdenis You can use my implementation in #61. I don't think it will get into the jBBCode's codebase that fast.