Unknown

Points that field can contain data of any type and this will NOT be considered as corruption and converted as is.

But still field can't be undefined or null, if this is acceptable values isNullable flag should be setted in initialization context

class User {
   public id: string;
   public something: unknown;
}

const somethingField = new UnknownField();

const USER_META = new ObjectMeta({
   builder: User,
   fields: {
      id: new StringField(),
      something: somethingField,
   }
});

const values = [
   {
      id: `1`,
   },
   {
      id: `2`,
      something: 4
   },
   {
      id: `3`,
      something: { one: 1 }
   },
];

const result = JTC.convert({
   id: `Boolean Truthy`,
   meta: new ObjectArrayMeta({ meta: USER_META }),
   values,
});

const log = JTC.log.asString(result.tree);

console.log(result.converted.all);

/* 0 -> something -> undefined | Value is absent*/
console.log(log);

Last updated

Was this helpful?