Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Implement expected Input::isValid workflow #7474

Merged
merged 10 commits into from
May 4, 2015

Conversation

weierophinney
Copy link
Member

This patch implements the logic I outlined in a comment to #7448:

  • required === true + allow_empty === true + continue_if_empty === false -> validators are NOT run
  • required === true + allow_empty === true + continue_if_empty === true -> validators are run
  • required === true + allow_empty === false + continue_if_empty === false -> validators are NOT run
  • required === true + allow_empty === false + continue_if_empty === true -> validators are run
  • required === false + allow_empty === true + continue_if_empty === false -> validators are NOT run
  • required === false + allow_empty === true + continue_if_empty === true -> validators are run
  • required === false + allow_empty === false + continue_if_empty === false -> validators are NOT run
  • required === false + allow_empty === false + continue_if_empty === true -> validators are run

It builds on the patch of #7448, and addresses the BC break demonstrated in #7445 and in zfcampus/zf-content-validation#46.

Martin-P and others added 10 commits April 4, 2015 23:24
…ql-process-expression

Get correct expression string when Zend\Db\Sql\Expression is used
…xpression

Test for percentage sign in Zend\Db\Sql\Expression
- Primarily long lines
- Primarily long lines
…r-input-random-specs-order

Allow use of setRequired() at different positions
This patch clarifies the interaction of the various flags when
validating an input. In it, I added test cases for the various
behaviors

- `required === true` + `allow_empty === true` + `continue_if_empty === false` -> validators are NOT run
- `required === true` + `allow_empty === true` + `continue_if_empty === true` -> validators are run
- `required === false` + `allow_empty === true` + `continue_if_empty === false` -> validators are NOT run
- `required === false` + `allow_empty === true` + `continue_if_empty === true` -> validators are run
- `required === false` + `allow_empty === false` + `continue_if_empty === false` -> validators are NOT run
- `required === false` + `allow_empty === false` + `continue_if_empty === true` -> validators are run

Changes were applied to `setRequired()`, which now no longer toggles
`allow_empty`, and the logic in `Input::isValid()` and
`FileInput::isValid()` was updated to match the above.

Two tests were removed as they were testing false assumptions:

- `BaseInputFilterTest::testValidationMarksInputInvalidWhenNotRequiredAndAllowEmptyFlagIsFalse`
- `FactoryTest::testFactoryWillCreateInputWithSuggestedRequiredFlagAndImpliesAllowEmptyFlag`
- `required === true` + `allow_empty === false` + `continue_if_empty === false` -> validators are NOT run
- `required === true` + `allow_empty === false` + `continue_if_empty === true` -> validators are run
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants