Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cstdenis opened this issue Jul 5, 2015 · 3 comments

Comments

@cstdenis
Copy link

cstdenis commented Jul 5, 2015

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
Copy link
Contributor

Kubo2 commented Jul 6, 2015

-Assigned:
+Assigned: Kubo2

just to not forget about this one

Kubo2 added a commit to Kubo2/jBBCode that referenced this issue Jul 28, 2015
…loses jbowens#60]

From this commit, it is possible to:

 - pass either InputValidor or a callable to both:
   - CodeDefinitionBuilder::setOptionValidator()
   - CodeDefinitionBuilder::setBodyValidator()
 - wrap any method or function into JBBCode\validators\CallableValidatorAdapter
   without need to manually implement InputValidator (this is also what internally
   CodeDefinitionBuilder does)
@Kubo2
Copy link
Contributor

Kubo2 commented Jul 28, 2015

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

Kubo2 added a commit to Kubo2/jBBCode that referenced this issue Jul 28, 2015
…loses jbowens#60]

From this commit, it is possible to:

 - pass either InputValidor or a callable to both:
   - CodeDefinitionBuilder::setOptionValidator()
   - CodeDefinitionBuilder::setBodyValidator()
 - wrap any method or function into JBBCode\validators\CallableValidatorAdapter
   without need to manually implement InputValidator (this is also what internally
   CodeDefinitionBuilder does)
Kubo2 added a commit to Kubo2/jBBCode that referenced this issue Jul 28, 2015
…loses jbowens#60]

From this commit, it is possible to:

 - pass either InputValidor or a callable to both:
   - CodeDefinitionBuilder::setOptionValidator()
   - CodeDefinitionBuilder::setBodyValidator()
 - wrap any method or function into JBBCode\validators\CallableValidatorAdapter
   without need to manually implement InputValidator (this is also what internally
   CodeDefinitionBuilder does)
Kubo2 added a commit to Kubo2/jBBCode that referenced this issue Jul 28, 2015
Kubo2 added a commit to Kubo2/jBBCode that referenced this issue Jul 28, 2015
@Kubo2
Copy link
Contributor

Kubo2 commented Mar 9, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants