On Mon, Aug 29, 2022 at 10:50 AM juan carlos morales < dev.juan.mora...@gmail.com> wrote:
> There is still 1 open question on the RFC, and is about the return value. > > https://wiki.php.net/rfc/json_validate#open_issuesquestions > > I would appreciate your feedback on this. Even though I was told the > RFC can go with 2 votings, I would like to know your thoughts about > that open question, in short, the return value. > Has the option of returning a Result object been discussed/considered? Can it be an option? I imagine that if `json_validate(): JsonValidationResult` always returns a `JsonValidationResult` which contains a `public readonly bool $valid` and a `public readonly ?string $error` it would be better than both options on the table right now. The option of returning CLI-like results means that we will need a `if (! json_validate())` to treat a valid JSON (really awkward) and the option of using `json_last_error()` relies on an internal state instead of an immutable structure. Effectively, what we need is to return a complex structure which can contain a boolean and a string and that is a class/object. Thoughts? -- Marco Deleu