-
Notifications
You must be signed in to change notification settings - Fork 356
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
Validator object appears to keep its validation status #385
Comments
@CMCDragonkai Thanks for letting us know - will take a look now, stand by. |
@CMCDragonkai It's already possible to reset the validation status - just use <?php
use JsonSchema\Validator;
require('vendor/autoload.php');
$v = new Validator();
$validSchema = json_decode('{"type":"string"}');
$invalidSchema = json_decode('{"type":"object"}');
$data = json_decode('"ABC"');
$v->validate($data, $invalidSchema);
assert(!$v->isValid());
$v->reset(); // This line resets isValid
$v->validate($data, $validSchema);
assert($v->isValid()); For the sake of usability, I have added this call in PR #386 , which will allow object reuse without needing to manually reset it. |
See #390 - The built-in reset will be official in 6.0.0 |
Can we maybe update the documentation for 5.x while we wait for 6.x. I've just spent a long while trying to work out what was going wrong digging through the source to find this, especially as the current docs don't mention |
PRs welcome |
@aboyton The main problem is that this project is woefully short of manpower, and contains a massive amount of legacy code that dates to well before any of us were involved with it. There aren't many active contributors, and none of us have much time available. In order to update the documentation, somebody would need to commit the time to do it. It's on my list, but there are other things that are higher priority than writing documentation for 5.x, and I don't have much time available at present. As @bighappyface mentioned above, PRs are always welcome - if you would like to submit documentation for 5.x, we'd love to have it. Otherwise, regrettably, there will be something of a wait. In the meantime, if you have specific questions, please feel free to ask, and I'll do my best to assist you. I'm very aware that the documentation is significantly lacking. You may also wish to refer to #440 - this PR is a work in progress that adds better PHPDoc comments to the public API. It's only partly complete, but hopefully it helps a little in the interim. |
Sorry I realised that I never replied to this nor made a pull request. Thanks for your work on this, I've made a small pull request with a sentence added for calling |
I'm using 5.1 version.
There should be a way to clear the Validator status? Or that subsequent invocations of validate should not keep the original validation status.
The text was updated successfully, but these errors were encountered: