mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support nested nullable objects

kettanaito opened this issue · comments

  • Originated from #202

This has to be supported:

const db = factory({
  user: {
    id: primaryKey(String),
    permissions: nullable(() => ({
      id: String,
    })),
  },
})

But it's not. Recursive nullable objects as well. No primary key needed. An API without a getter function would be preferable: nullable({ ... }).

commented

@kettanaito I'll give this a crack 😉

commented

See PR #219 👍 😃

Hi guys,

I opened a new PR for solving this issue with an api that doesn't use a nullable getter as @kettanaito asked
Can someone please take a look at it here ?

@kettanaito @abitbetterthanyesterday please let me know if this solution is acceptable and if so I will add some notes about it in the documentation

Thanks