nope-validator
Version:
Fast and simple JS validator
23 lines (22 loc) • 1.02 kB
TypeScript
import { Validatable, ShapeErrors, Context } from './types';
interface ObjectShape {
[key: string]: Validatable<any> | NopeObject;
}
declare type ValidateOptions = {
abortEarly: boolean;
};
declare type AnyObject = Record<string | number, any>;
export declare class NopeObject {
private objectShape;
private validationRules;
protected _type: string;
constructor(objectShape?: ObjectShape);
getType(): string;
shape(shape: ObjectShape): this;
extend(Base: NopeObject): this;
noUnknown(message?: string): this;
validate(entry: AnyObject, context?: AnyObject | null, options?: ValidateOptions): string | ShapeErrors | import("./NopePrimitive").NopePrimitive<AnyObject> | Promise<string | import("./NopePrimitive").NopePrimitive<AnyObject> | undefined> | undefined;
validateAsync(entry: AnyObject, context?: Context, options?: Omit<ValidateOptions, 'abortEarly'>): any;
validateAt(path: string, entry: Record<string | number, any>): any;
}
export {};