public function required_without($str = null, string $fields, array $data): bool
	{
		$fields = explode(',', $fields);

		// If the field is present we can safely assume that
		// the field is here, no matter whether the corresponding
		// search field is present or not.
		$present = $this->required($str ?? '');

		if ($present)
		{
			return true;
		}

		// Still here? Then we fail this test if
		// any of the fields are not present in $data
		foreach ($fields as $field)
		{
			if (! array_key_exists($field, $data))
			{
				return false;
			}
		}

		return true;
	}
public function required_without($str = null, string $fields, array $data): bool
	{
		$fields = explode(',', $fields);

		// If the field is present we can safely assume that
		// the field is here, no matter whether the corresponding
		// search field is present or not.
		$present = $this->required($str ?? '');

		if ($present)
		{
			return true;
		}

		// Still here? Then we fail this test if
		// any of the fields are not present in $data
		foreach ($fields as $field)
		{
			if (! array_key_exists($field, $data))
			{
				return false;
			}
		}

		return true;
	}
public function required_without ( $ str = null , string $ fields , array $ data ) : bool { $ fields = explode ( ',' , $ fields ) ; // If the field is present we can safely assume that // the field is here, no matter whether the corresponding // search field is present or not. $ present = $ this -> required ( $ str ?? '' ) ; if ( $ present ) { return true ; } // Still here? Then we fail this test if // any of the fields are not present in $data foreach ( $ fields as $ field ) { if ( ! array_key_exists ( $ field , $ data ) ) { return false ; } } return true ; }
The field is required when all of the other fields are present
in the data but not required.

Example (field is required when the id or email field is missing):

required_without[id,email]

@param $str
@param string $fields
@param array  $data

@return boolean
The field is required when all of the other fields are present in the data but not required .