convert object to string if possible instead of using var_export directly
merged branch bes89/validator_object_to_string (PR #9036)

This PR was submitted for the 2.3 branch but it was merged into the master branch instead (closes #9036).

Discussion
----------

[Validator] convert object to string if possible instead of using var_export directly

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

2149146 [Validator] convert object to string if possible instead of using var_export directly