mirror of
https://github.com/Respect/Validation.git
synced 2024-06-27 17:50:13 +02:00
Merge branch 'marcelo-develop' into develop
This commit is contained in:
commit
182425ee0a
|
@ -46,12 +46,14 @@ abstract class AbstractComposite extends AbstractRule implements Validatable
|
|||
{
|
||||
if (empty($this->rules))
|
||||
return false;
|
||||
elseif ($validator instanceof Valitatable)
|
||||
|
||||
if ($validator instanceof Valitatable)
|
||||
return isset($this->rules[spl_object_hash($validator)]);
|
||||
else
|
||||
foreach ($this->rules as $rule)
|
||||
if ($rule instanceof $validator)
|
||||
return true;
|
||||
|
||||
foreach ($this->rules as $rule)
|
||||
if ($rule instanceof $validator)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -106,4 +108,4 @@ abstract class AbstractComposite extends AbstractRule implements Validatable
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -18,24 +18,24 @@ class Contains extends AbstractRule
|
|||
{
|
||||
if ($this->identical)
|
||||
return $this->validateIdentical($input);
|
||||
else
|
||||
return $this->validateEquals($input);
|
||||
|
||||
return $this->validateEquals($input);
|
||||
}
|
||||
|
||||
protected function validateEquals($input)
|
||||
{
|
||||
if (is_array($input))
|
||||
return in_array($this->containsValue, $input);
|
||||
else
|
||||
return false !== mb_stripos($input, $this->containsValue);
|
||||
|
||||
return false !== mb_stripos($input, $this->containsValue);
|
||||
}
|
||||
|
||||
protected function validateIdentical($input)
|
||||
{
|
||||
if (is_array($input))
|
||||
return in_array($this->containsValue, $input, true);
|
||||
else
|
||||
return false !== mb_strpos($input, $this->containsValue);
|
||||
|
||||
return false !== mb_strpos($input, $this->containsValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,4 +71,4 @@ class Contains extends AbstractRule
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -23,12 +23,14 @@ class In extends AbstractRule
|
|||
{
|
||||
if (is_array($this->haystack))
|
||||
return in_array($input, $this->haystack, $this->compareIdentical);
|
||||
elseif (!is_string($this->haystack))
|
||||
|
||||
if (!is_string($this->haystack))
|
||||
return false;
|
||||
elseif ($this->compareIdentical)
|
||||
|
||||
if ($this->compareIdentical)
|
||||
return mb_strpos($this->haystack, $input) !== false;
|
||||
else
|
||||
return mb_stripos($this->haystack, $input) !== false;
|
||||
|
||||
return mb_stripos($this->haystack, $input) !== false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,4 +66,4 @@ class In extends AbstractRule
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -18,24 +18,24 @@ class StartsWith extends AbstractRule
|
|||
{
|
||||
if ($this->identical)
|
||||
return $this->validateIdentical($input);
|
||||
else
|
||||
return $this->validateEquals($input);
|
||||
|
||||
return $this->validateEquals($input);
|
||||
}
|
||||
|
||||
protected function validateEquals($input)
|
||||
{
|
||||
if (is_array($input))
|
||||
return reset($input) == $this->startValue;
|
||||
else
|
||||
return 0 === mb_stripos($input, $this->startValue);
|
||||
|
||||
return 0 === mb_stripos($input, $this->startValue);
|
||||
}
|
||||
|
||||
protected function validateIdentical($input)
|
||||
{
|
||||
if (is_array($input))
|
||||
return reset($input) === $this->startValue;
|
||||
else
|
||||
return 0 === mb_strpos($input, $this->startValue);
|
||||
|
||||
return 0 === mb_strpos($input, $this->startValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,4 +71,4 @@ class StartsWith extends AbstractRule
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue