protected function cleanValidationRules(array $rules, array $data = null): array
	{
		if (empty($data))
		{
			return [];
		}

		foreach ($rules as $field => $rule)
		{
			if (! array_key_exists($field, $data))
			{
				unset($rules[$field]);
			}
		}

		return $rules;
	}
protected function cleanValidationRules(array $rules, array $data = null): array
	{
		if (empty($data))
		{
			return [];
		}

		foreach ($rules as $field => $rule)
		{
			if (! array_key_exists($field, $data))
			{
				unset($rules[$field]);
			}
		}

		return $rules;
	}
protected function cleanValidationRules ( array $ rules , array $ data = null ) : array { if ( empty ( $ data ) ) { return [ ] ; } foreach ( $ rules as $ field => $ rule ) { if ( ! array_key_exists ( $ field , $ data ) ) { unset ( $ rules [ $ field ] ) ; } } return $ rules ; }
Removes any rules that apply to fields that have not been set
currently so that rules don't block updating when only updating
a partial row.

@param array      $rules

@param array|null $data

@return array
Removes any rules that apply to fields that have not been set currently so that rules don t block updating when only updating a partial row .