Will check input if it is scalars or elements, or arrays of these
@param mixed $val
@return bool
480842
protected function validValue(&$val)
    {
        if (!is_array($val)) {
            return $val == null || is_scalar($val) || $val instanceof JsonSerializable;
        }

        foreach ($val as $k => $v) {
            if (!$this->validValue($v)) {
                $val[$k] = null;
            } else {
                $val[$k] = $v;
            }
        }
        return true;
    }
61286
public static function distinct($val): bool
    {
        if (!$val || !\is_array($val)) {
            return false;
        }

        return \array_unique($val) === $val;
    }
1070158
public function contains($value): bool
    {
        return \in_array($value, $this->items, (is_scalar($value) ? false : true));
    }
1032348
function isArraySimpleOrStruct($val) {
        $keyList = array_keys($val);
		foreach ($keyList as $keyListValue) {
			if (!is_int($keyListValue)) {
				return 'arrayStruct';
			}
		}
		return 'arraySimple';
	}
1194588
protected function Eq( $val )
	{
		if ( ! $val instanceof BoolProxy ) return false;
		return  ( $this->_value instanceof CoreFuncs::$False && $val->getValue() instanceof CoreFuncs::$False ) ||
				( $this->_value instanceof CoreFuncs::$True && $val->getValue() instanceof CoreFuncs::$True ) ||
				( is_bool( $this->_value ) && is_bool( $val->getValue() ) && $this->_value == $val->getValue() );
		// return $this->_value == (bool)$val->_value;
	}
645416
protected function Eq( $val )
	{
		$result = $this->_value == $val->getValue();

		if ( $result ||
			 is_infinite( $this->_value ) ||
			 is_nan( $this->_value ) ||
			 is_infinite( $val->getValue() ) ||
			 is_nan( $val->getValue() ) )
		{
			return $result;
		}

		$a = $this->_value;
		$b = $val->getValue();
		$limit = pow( 2, 31 );

		if ( abs( $a ) < $limit && abs( $b ) < $limit )
		{
			return $a == $b;
		}

		$expectedDecimal = DecimalValue::FromFloat( $a, false );
		$actualDecimal   = DecimalValue::FromFloat( $b, false );

		$expectedDecimalLength = $expectedDecimal->getIsDecimal() ? strlen( $expectedDecimal->getDecimalPart() ) : 0;
		$actualDecimalLength = $actualDecimal->getIsDecimal() ? strlen( $actualDecimal->getDecimalPart() ) : 0;

		$expectedDigitsLength = strlen( $expectedDecimal->getIntegerPart() );
		$actualDigitsLength = strlen( $actualDecimal->getIntegerPart() );

		// Make sure they have the same number of decimals
		if ( $expectedDecimalLength != $actualDecimalLength )
		{
			if ( $expectedDecimalLength > $actualDecimalLength )
			{
				$expectedDecimal = $expectedDecimal->getRound( $actualDecimalLength );
			}
			else
			{
				$actualDecimal = $actualDecimal->getRound( $expectedDecimalLength );
			}
		}

		if ( ! $expectedDecimal->getIsDecimal() && $expectedDigitsLength == $actualDigitsLength )
		{
			// Make sure they are the same length after removing trailing zeros. This will required when
			// the values are say 1.23E6 (which will be decimal 123000) and 1.234E6 (123400).  OK these are
			// simplified examples.  A concrete example is 1.234567890123456E38 and 1.2345678901235E38
			$expectedDigits = rtrim( $expectedDecimal->getIntegerPart(), "0" );
			if ( strlen( $expectedDigits ) == 0 ) $expectedDigits = "0";
			$actualDigits = rtrim( $actualDecimal->getIntegerPart(), "0" );
			if ( strlen( $actualDigits ) == 0 ) $actualDigits = "0";

			if ( strlen( $expectedDigits ) > strlen( $actualDigits ) )
			{
				$expectedDecimal = DecimalValue::FromValue( $expectedDigits )->getRound( strlen( $actualDigits ) - strlen( $expectedDigits ) );
				$factor = DecimalValue::FromValue( 10 )->Pow( $actualDigitsLength - strlen( $expectedDigits ) );
				$expectedDecimal = $expectedDecimal->Mul( $factor );
			}
			else if ( strlen( $expectedDigits ) < strlen( $actualDigits ) )
			{
				$actualDecimal = DecimalValue::FromValue( $actualDigits )->getRound( strlen( $expectedDigits ) - strlen( $actualDigits ), PHP_ROUND_HALF_DOWN );
				$factor = DecimalValue::FromValue( 10 )->Pow( $expectedDigitsLength - strlen( $actualDigits ) );
				$actualDecimal = $actualDecimal->Mul( $factor );
			}
		}
		else
		{
			// If the digits are not the same length ???
		}

		$result = $expectedDecimal->Equals( $actualDecimal );

		return $result;
	}
1198614
public function _validation_valid_emails($val, $separator = ',')
	{
		if ($this->_empty($val))
		{
			return true;
		}

		$emails = explode($separator, $val);

		foreach ($emails as $e)
		{
			if ( ! filter_var(trim($e), FILTER_VALIDATE_EMAIL))
			{
				return false;
			}
		}
		return true;
	}
960656
public function exsitsIn($array, $val)
	{
		foreach ($array as $key => $value) {
			$keys =  explode('|', $value);
			foreach ($keys as $k) {
				$recs = DB::table($key)->where($k, $val)->get();
				if(count($recs)) return true;
			}	
		}

		return false;
	}
1114225
public function isSameTypeAs($value): bool
    {
        if (!is_array($value) && !$value instanceof Traversable) {
            return false;
        }

        foreach ($value as $key => $val) {
            if (!($this->key->isSameTypeAs($key) && $this->value->isSameTypeAs($val))) {
                return false;
            }
        }

        return true;
    }
366111
public static function trim($val)
    {
        return \is_array($val) ? \array_map(function ($val) {
            return \is_string($val) ? \trim($val) : $val;
        }, $val) : \trim((string)$val);
    }
1001278
private function validate( $values ) {

		$is_valid = TRUE;

		foreach ( $values as $key => $value ) {

			if ( ! is_scalar( $value ) ) {
				continue;
			}

			foreach ( $this->validators as $validator ) {
				$is_valid = $validator->is_valid( $value );

				if ( ! $is_valid ) {
					$this->error_messages[ $key ] = $validator->get_error_messages();
					break;
				}
			}

			if ( ! $is_valid ) {
				break;
			}
		}

		return $is_valid;
	}
977556
public static function string($val, $minLen = 0, $maxLen = null): bool
    {
        if (!\is_string($val)) {
            return false;
        }

        // only type check.
        if ($minLen === 0 && $maxLen === null) {
            return true;
        }

        return self::integer(Helper::strlen($val), $minLen, $maxLen);
    }
951211
public function isSelected($val)
    {
        if ($this->isMulti()) {
            return in_array($val, $this->getValue());
        } else {
            return $val === $this->getValue();
        }
    }
1094162
public function arrayToBinary($val)
    {
        $saved_object_count = $this->writtenObjectCount++;

        $bdata = self::typeBytes("a", count($val->getValue())); // a is 1010, type indicator for arrays

        foreach ($val as $v) {
            $bval = $v->toBinary($this);
            $bdata .= self::packItWithSize($this->objectRefSize, $bval);
        }

        $this->objectTable[$saved_object_count] = $bdata;
        return $saved_object_count;
    }
128068
public static function isSelfDescribing($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $val = (string) $val;
        for ($i=0; $i<strlen($val); $i++) {
            $_val   = $val{$i};
            $occ    = substr_count($val, $i);
            if ($_val != $occ) {
                return false;
            }
        }
        return true;
    }
891154
public static function alphaNum($val): bool
    {
        if (!\is_string($val) && !\is_numeric($val)) {
            return false;
        }

        return 1 === \preg_match('/^(?:[a-zA-Z0-9]+)$/', $val);
    }
1097146
private function isRelevantForMainPage($val)
    {
        return (substr($val['$ref'], -1) === '/')
            || in_array(parse_url($val['$ref'], PHP_URL_PATH), $this->pathWhitelist);
    }