🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

desy

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

desy - npm Package Compare versions

Comparing version
0.0.15
to
0.0.16
+10
dist/types/array/array.d.ts
import { Infer, Schema } from '../schema/schema.ts';
import { ConfigValue } from '../types.ts';
export declare class ArrayDesy<TSchema extends Schema<any>> extends Schema<Infer<TSchema>[]> {
static new<TSchema extends Schema<any>>(config: ConfigValue<TSchema>): ArrayDesy<TSchema>;
constructor(config: ConfigValue<TSchema>);
min(minLength: number): this;
max(maxLength: number): this;
length(length: number): this;
}
export declare function array<TValue extends Schema<any>>(schema: TValue): ArrayDesy<TValue>;
import { Schema } from '../schema/schema.ts';
import { type Config } from '../types.ts';
export declare class BooleanDesy<TValue extends boolean = boolean> extends Schema<TValue> {
static new<TValue extends boolean>(config: Config): BooleanDesy<TValue>;
constructor(config: Config);
true(): BooleanDesy<true>;
false(): BooleanDesy<false>;
}
export declare function boolean(): BooleanDesy<boolean>;
export type Test = (value: any, { path }: {
path: string;
}) => string;
export type TestEntity = {
name: string;
test: Test;
};
export declare class Context {
static new(): Context;
rules: TestEntity[];
allowNull: boolean;
allowUndefined: boolean;
}
import { Schema } from '../schema/schema.ts';
import { Config } from '../types';
type DateValue = string | number | Date;
export declare class DateDesy<TValue extends DateValue> extends Schema<TValue> {
static new(config: Config): DateDesy<DateValue>;
constructor(config: Config);
min(min: DateValue): this;
max(max: DateValue): this;
}
export declare function date(): DateDesy<DateValue>;
export {};
import { string } from './string/string.ts';
import { object } from './object/object.ts';
import { number } from './number/number.ts';
import { boolean } from './boolean/boolean.ts';
import { array } from './array/array.ts';
import { mixed } from './mixed/mixed.ts';
import { date } from './date/date.ts';
import { nullDesy } from './null/null.ts';
import { type Schema, type Infer } from './schema/schema.ts';
export { type Schema } from './schema/schema.ts';
export type InferDesy<T extends Schema<any>> = Infer<T>;
export declare const d: {
string: typeof string;
object: typeof object;
number: typeof number;
boolean: typeof boolean;
array: typeof array;
mixed: typeof mixed;
date: typeof date;
null: typeof nullDesy;
};
export type DefaultMessageProps = {
path: string;
};
type Min = DefaultMessageProps & {
min: number;
};
type Max = DefaultMessageProps & {
max: number;
};
type Length = DefaultMessageProps & {
length: number;
};
type RegexpMessage = DefaultMessageProps & {
regexp: string;
};
export declare const messages: {
string: {
string: ({ path }: DefaultMessageProps) => string;
requred: ({ path }: DefaultMessageProps) => string;
min: ({ path, min }: Min) => string;
max: ({ path, max }: Max) => string;
length: ({ path, length }: Length) => string;
regexp: ({ path, regexp }: RegexpMessage) => string;
one_of: ({ path, variants, value, }: DefaultMessageProps & {
variants: string[];
value: string;
}) => string;
};
object: {
object: ({ path }: DefaultMessageProps) => string;
no_property: ({ path }: DefaultMessageProps) => string;
unknown: ({ path }: DefaultMessageProps) => string;
};
mixed: {
not_void: ({ path }: DefaultMessageProps) => string;
};
boolean: {
boolean: ({ path }: DefaultMessageProps) => string;
true: ({ path }: DefaultMessageProps) => string;
false: ({ path }: DefaultMessageProps) => string;
};
number: {
number: ({ path }: DefaultMessageProps) => string;
min: ({ path, min }: Min) => string;
max: ({ path, max }: Max) => string;
int: ({ path }: DefaultMessageProps) => string;
float: ({ path }: DefaultMessageProps) => string;
};
array: {
array: ({ path }: DefaultMessageProps) => string;
items: ({ path }: DefaultMessageProps) => string;
min: ({ path, min }: Min) => string;
max: ({ path, max }: Max) => string;
length: ({ path, length }: Length) => string;
};
date: {
date: ({ path }: DefaultMessageProps) => string;
min: ({ path, min }: DefaultMessageProps & {
min: string;
}) => string;
max: ({ path, max }: DefaultMessageProps & {
max: string;
}) => string;
};
null: {
null: ({ path }: DefaultMessageProps) => string;
};
};
export {};
import { Infer, Schema } from '../schema/schema.ts';
import { StringDesy as StringDesy } from '../string/string.ts';
import { type ObjectDesyValue, ObjectDesy } from '../object/object.ts';
import { BooleanDesy } from '../boolean/boolean.ts';
import { type Config } from '../types.ts';
import { NumberDesy } from '../number/number.ts';
import { ArrayDesy } from '../array/array.ts';
import { NullDesy } from '../null/null.ts';
import { DateDesy } from '../date/date.ts';
export declare class MixedDesy<TValue extends any = any> extends Schema<TValue> {
static new(config: Config): MixedDesy<any>;
array<TValue extends Schema<any>>(schema: TValue): ArrayDesy<TValue>;
number(): NumberDesy;
object<TValue extends ObjectDesyValue>(shape: TValue): ObjectDesy<TValue, { [K in keyof TValue]: Infer<TValue[K]>; }>;
boolean(): BooleanDesy<boolean>;
string(): StringDesy<string>;
date(): DateDesy<string | number | Date>;
null(): NullDesy;
notVoid(): this;
oneOf<TValue extends Schema<any>>(schemas: TValue[]): MixedDesy<Infer<TValue>>;
}
export declare function mixed(): MixedDesy<any>;
import { Schema } from '../schema/schema.ts';
import { Config } from '../types.ts';
export declare class NullDesy extends Schema<null> {
static new(config: Config): NullDesy;
constructor(config: Config);
}
export declare function nullDesy(): NullDesy;
import { Schema } from '../schema/schema.ts';
import { Config } from '../types.ts';
export declare class NumberDesy extends Schema<number> {
static new(config: Config): NumberDesy;
constructor(config: Config);
min(min: number): this;
max(max: number): this;
int(): this;
float(): this;
}
export declare function number(): NumberDesy;
import { Schema, type Infer } from '../schema/schema.ts';
import { type ConfigValue } from '../types.ts';
export type ObjectDesyValue = Record<string, Schema<any>>;
type PreparedTypes<TValue extends ObjectDesyValue> = {
[K in keyof TValue]: Infer<TValue[K]>;
};
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export declare class ObjectDesy<TValue extends ObjectDesyValue, TValueTypes = PreparedTypes<TValue>> extends Schema<TValueTypes> {
static new<TValue extends ObjectDesyValue>(config: ConfigValue<TValue>): ObjectDesy<TValue, PreparedTypes<TValue>>;
value: TValue;
constructor(config: ConfigValue<TValue>);
notStrict(): ObjectDesy<TValue, Partial<this["types"]>>;
optionalFields<TValueLocal extends keyof TValueTypes & string = any>(optionalFields: TValueLocal[]): ObjectDesy<TValue, PartialBy<this["types"], TValueLocal>>;
}
export declare function object<TValue extends ObjectDesyValue>(value: TValue): ObjectDesy<TValue, PreparedTypes<TValue>>;
export {};
import { Context, Test } from '../context/context.ts';
type Config = {
context: Context;
};
export type Infer<TType extends Schema<any>> = TType['types'];
type ConfigValidate = {
path: string;
};
export declare abstract class Schema<TValue> {
types: TValue;
protected context: Context;
constructor({ context }: Config);
validate(value: any, { path }?: ConfigValidate): string;
nullable(): Schema<TValue | null>;
undefinable(): Schema<TValue | undefined>;
optional(): Schema<TValue | null | undefined>;
validateObj(value: any, config?: ConfigValidate): Infer<typeof this> | string;
test<TValue extends (typeof this)['types']>(cb: Test): Schema<TValue>;
}
export {};
import { DefaultMessageProps } from '../messages.ts';
import { Schema } from '../schema/schema.ts';
import { Context } from '../context/context.ts';
type Config = {
context: Context;
};
export declare class StringDesy<TValue extends string> extends Schema<TValue> {
static new<TValue extends string>(config: Config): StringDesy<TValue>;
static string(value: any, { path }: DefaultMessageProps): string;
static required(value: string, { path }: DefaultMessageProps): string;
constructor(config: Config);
optional(): Schema<TValue | null | undefined>;
length(length: number): this;
min(minLength: number): this;
max(maxLength: number): this;
oneOf<TValue extends readonly string[]>(variants: TValue): StringDesy<TValue[number]>;
regexp(regexp: RegExp): this;
}
export declare function string(): StringDesy<string>;
export {};
import { type Context } from './context/context.ts';
export type Config = {
context: Context;
};
export type ConfigValue<TValue> = {
value: TValue;
context: Context;
};
+1
-1
{
"name": "desy",
"version": "0.0.15",
"version": "0.0.16",
"type": "module",

@@ -5,0 +5,0 @@ "types": "./dist/types/desy.d.ts",