Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { assert, IsExact } from 'conditional-type-checks';
interface ConstraintToken extends Constraint {
name: string;
new(...args: any[]): V;
}
function convertConstraint>(constraint: T, name?: string): ConstraintToken> {
constraint['name'] = name ? `${name} ${constraint['tag']}` : constraint['tag'];
guard()(constraint, 'guard');
return constraint as any;
}
const dynamo = new Dynamo();
const nameConstraint = StringType.withConstraint(x => {
return x.length > 0;
});
// tslint:disable-next-line:variable-name
const Name = convertConstraint(nameConstraint);
type Name = InstanceType;
const ageConstraint = NumberType.withConstraint(n => {
return Number.isInteger(n) && n >= 0;
});
// tslint:disable-next-line:variable-name
const Age = convertConstraint(ageConstraint);
type Age = InstanceType;
const personRecord = Record({