0.2.0 • Published 7 months ago

@criterium/typebox v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

@criterium/typebox

@criterium/typebox create typebox query schema for given typebox entity schema.

install

npm i @criterium/typebox

usage

import { Type as t } from '@sinclair/typebox';
import { queryOf } from '@criterium/typebox';
import { Value } from '@sinclair/typebox/value';

const User = t.Object({
  name: t.String(),
  address: t.Object({
    street: t.String(),
  }),
});

const UserQuery = queryOf(t, User);

Value.Check(UserQuery, {
  address: {
    street: {
      $in: ['SF', 'NY'],
    },
  },
})
// success

Value.Check(UserQuery, {
  is_admin: {
    $eq: true,
  },
})
// fail
0.2.0

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago

0.0.1

7 months ago