Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Possibility fail if constraint is unknown #132

Open
peterpostmann opened this issue Nov 27, 2017 · 0 comments
Open

Possibility fail if constraint is unknown #132

peterpostmann opened this issue Nov 27, 2017 · 0 comments

Comments

@peterpostmann
Copy link
Contributor

Hi Matt,

I want to continue the discussion from #130: I have full understanding that you want to limit the scope of the library to what is supported by the specification.

My problem is, that there is right now no possibility to intercept the validation process.

if (!$this->ruleSet->has($keyword)) {
return null;
}

I really need this feature and hence I kindly ask for your support. Aside from the requested change I see two other ways to make the validation interceptable. Maybe one of those is causing less maintenance, etc. effort.

1. Move the validation logic to the ruleset

Validator.php

    private function validateRule($keyword, $parameter)
    {
        return $this->ruleSet->validate($keyword)->validate($this->data, $parameter, $this);
    }

RuleSetContainer.php

    public function validate($keyword, $data, $parameter, $validator)
    {
        if (!$this->has($keyword)) {
            return null;
        }
        return $this->get($keyword)->validate($data, $parameter, $validator);
    }

2. Make Validator.php extendable

i.e. remove the final keyword and make validateRule protected instead of private.

Looking forward to your feedback!

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

No branches or pull requests

1 participant