Boolean

Creation

class User {
   public isAdmin: boolean;
}

const isAdminField = new BooleanField();

const USER_META = new ObjectMeta({
   builder: User,
   fields: {
      isAdmin: isAdminField,
   }
});

const values = [
   {
      isAdmin: true,
   },
   {
      isAdmin: 0,
   }
];

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

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

console.log(result.converted.all);

/* 1 (EXCLUDED) -> {...} | Validation failed for all fields
   1 (EXCLUDED) -> isAdmin -> 0 | Expected boolean, but got number */
console.log(log);

Validation

Last updated