@vulcan-sql/core
Version:
Core package of VulcanSQL
73 lines (72 loc) • 2.69 kB
TypeScript
import { DiscriminatorDescriptor } from 'class-transformer';
export declare abstract class Constraint {
abstract __type: string;
static Required(): RequiredConstraint;
static MinValue(minValue: number, exclusive?: boolean): MinValueConstraint;
static MaxValue(maxValue: number, exclusive?: boolean): MaxValueConstraint;
static MinLength(minLength: number): MinLengthConstraint;
static MaxLength(maxLength: number): MaxLengthConstraint;
static Regex(regex: string): RegexConstraint;
static Enum<T = any>(list: Array<T>): EnumConstraint<T>;
static Type(type: TypeConstraintType): TypeConstraint;
abstract compose(constraint: Constraint): Constraint;
}
export declare class RequiredConstraint extends Constraint {
__type: string;
compose(): RequiredConstraint;
}
export declare class MinValueConstraint extends Constraint {
private minValue;
private exclusive;
__type: string;
constructor(minValue: number, exclusive?: boolean);
getMinValue(): number;
isExclusive(): boolean;
compose(constraint: MinValueConstraint): MinValueConstraint;
}
export declare class MaxValueConstraint extends Constraint {
private maxValue;
private exclusive;
__type: string;
constructor(maxValue: number, exclusive?: boolean);
getMaxValue(): number;
isExclusive(): boolean;
compose(constraint: MaxValueConstraint): MaxValueConstraint;
}
export declare class MinLengthConstraint extends Constraint {
private minLength;
__type: string;
constructor(minLength: number);
getMinLength(): number;
compose(constraint: MinLengthConstraint): MinLengthConstraint;
}
export declare class MaxLengthConstraint extends Constraint {
private maxLength;
__type: string;
constructor(maxLength: number);
getMaxLength(): number;
compose(constraint: MaxLengthConstraint): MaxLengthConstraint;
}
export declare class RegexConstraint extends Constraint {
private regex;
__type: string;
constructor(regex: string);
getRegex(): string;
compose(): RegexConstraint;
}
export declare class EnumConstraint<T = string> extends Constraint {
private list;
__type: string;
constructor(list: Array<T>);
getList(): T[];
compose(constraint: EnumConstraint<any>): EnumConstraint;
}
export declare type TypeConstraintType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
export declare class TypeConstraint extends Constraint {
private type;
__type: string;
constructor(type: TypeConstraintType);
getType(): TypeConstraintType;
compose(): TypeConstraint;
}
export declare const ConstraintDiscriminator: DiscriminatorDescriptor;