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

Deprecate validate() and add isValid() and isNotValid() #55

Closed
wants to merge 3 commits into from
Closed

Deprecate validate() and add isValid() and isNotValid() #55

wants to merge 3 commits into from

Conversation

rick-nu
Copy link

@rick-nu rick-nu commented Jun 5, 2015

What

To have better readable code, we decided it would be better to rename validate() to isValid(). Also adding isNotValid() was requested. Since the Validator API is still visible in one auto-completion popup, I think it won't be a problem to add it.

ToDo

  • Make sure that we want to add isNotValid()
  • Update documentation

How to test

  1. See that all tests pass with the new isValid() function
  2. See that validate() still works, but is now deprecated
  3. See that the documentation now also uses isValid()

@rick-nu
Copy link
Author

rick-nu commented Jun 5, 2015

image

@rick-nu rick-nu changed the title Depricate validate() and add isValid() and isNotValid() Deprecate validate() and add isValid() and isNotValid() Jun 5, 2015
@berry-langerak berry-langerak reopened this Jun 5, 2015
@localheinz
Copy link
Contributor

👍

@berry-langerak
Copy link
Member

Actually, @localheinz, "the jury is still out on this" ;) I'm very much in doubt on whether to do take this approach or moving the isValid and isNotValid to Particle\Validator\ValidationResult and making validate always return a ValidationResult instead. So:

$v = new Validator;
$v->required('name')->length(4);

$result = $v->validate(['name' => 'Jane']);
if ($result->isNotValid()) {
   print_r($result->getMessages());
}

What do you think about that?

@localheinz
Copy link
Contributor

@berry-langerak

Returning a ValidationResult makes sense to me, too. Totally fine with the result having methods like isValid() and isNotValid()!

@rick-nu
Copy link
Author

rick-nu commented Jun 11, 2015

I will pick that up then.

@rick-nu rick-nu closed this Jun 11, 2015
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

Successfully merging this pull request may close these issues.

None yet

3 participants