orbitjs / orbit

Composable data framework for ambitious web applications.
https://orbitjs.com
MIT License
2.33k stars 134 forks source link

validator has not been provided for attribute ... of `type` 'object' #857

Closed bradjones1 closed 3 years ago

bradjones1 commented 3 years ago

I am working with v0.17.0-beta.20 utilizing a json:api source pulled through an in-memory source. While syncing the record cache, the record is validated. I have a model for a file record type, with an attribute of object type specified thusly:

{
  "models": {
    "file": {
      "attributes": {
...
        "uri": {
          "type": "object"
        },
...
        }
      }
    }
  }
}

In SyncRecordCache::update, the validation fails with the following issue:

Screenshot from 2021-07-06 23-23-57

It appears this is related to https://github.com/orbitjs/orbit/pull/842 but as there is no documentation yet on 0.17 beyond the tests, I'm a bit stumped as to whether this is a:

bradjones1 commented 3 years ago

Looks like we're missing an object validator:

https://github.com/orbitjs/orbit/blob/e4a9395c830af8e4952a5fed1088f7cdd7e9edf1/packages/@orbit/validators/src/standard-validators.ts#L8-L29

dgeb commented 3 years ago

Good catch, @bradjones1.

In reviewing the validator logic, I found a few holes that I'm going to try to fill today:

I'll get a new beta out after this work is done.

In the mean time, if you want a workaround to avoid the above error you can provide a custom validatorFor function to your sources that includes a no-op validator (() => {}) for object.

dgeb commented 3 years ago

Just published:

bradjones1 commented 3 years ago

Wow! :rocket: Thanks!