import { themis } from '~/main'; import { doManyTests } from '~/tests/integration/helpers'; describe('Themis - Schema with Mixed Properties Test', () => { describe('case #1', () => { const schema = themis.schema({ id: themis.string({ min: 4, max: 6, required: true, }), date: themis.string({ match: /^\d{4}-\d{2}-\d{2}$/, }), value: themis.number({ required: true, min: -10, }), }); const testMany = doManyTests(schema); testMany.valid([ { id: '12345', date: '2010-08-10', value: 5, }, { id: '12345', value: 5, }, { id: '1234', value: -10, }, ]); testMany.invalid([ { id: '12345', date: '2010-08-10', }, { date: '2010-08-10', value: 5, }, { id: '12', date: '2010-08-10', value: 5, }, { id: '12345', date: '2010-08-10', value: -11, }, { id: '12345', date: 'batata', value: 5, }, {}, undefined, ]); }); });