json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

Accessing mapping discriminator from Schema

Open ivanwilliammd opened this issue 1 year ago • 1 comments

Dear all, I'm currently using schema downloaded here :

https://hl7.org/fhir/R4/fhir.schema.json.zip

Suppose that I would like to validate against Encounter Is this the correct code for that

    public function validation($request)
    {
        $validator = new Validator();
        $validator->resolver()->registerFile(
            'http://hl7.org/fhir/json-schema/4.0#/definitions/' . $this->resourceType,
            base_path('schema/fhir.schema.json')
        );

        $result = $validator->validate(
            $request->all(),
            'http://hl7.org/fhir/json-schema/4.0#/definitions/' . $this->resourceType
        );

        if ($result->isValid()) {
           return null;
        } else {
            // Print errors
            return (new ErrorFormatter())->format($result->error());
        }
    }

Since up until now it keep showing an error like this

{
    "message": "Method Illuminate\\Http\\Request::validated does not exist.",
    "exception": "BadMethodCallException",

Really appreciate and thankful for any help. Thanks

ivanwilliammd avatar Mar 25 '23 17:03 ivanwilliammd