altheia-async-data-validator
Version:
A very simple, fast and customizable async data validator
77 lines (76 loc) • 2.01 kB
TypeScript
import { TypeBase } from './base';
import { Validator } from '../validator';
import { LangList } from '../types/lang';
export declare const messages: LangList;
export interface OptionsIn {
oneErrorPerKey: boolean;
}
/**
* Object class
*/
export declare class TypeObject extends TypeBase {
/**
* Constructor
*/
constructor();
_cast(): void;
/**
* Test to validate the type of the value
*
* @return {this}
*/
typeof(): this;
/**
* Force an object to have only the keys passed in the set
*/
in(...array: string[]): this;
in(array: string[]): this;
in(array: string[], options: OptionsIn): this;
/**
* Force an object to not have the keys passed in the set
*
* @param {...string} array
* @return {this}
*/
not(...array: string[]): this;
not(array: string[]): this;
/**
* Validate an object with a fully qualified schema
*
* @param {Altheia} schema
* @param {boolean} options.returnErrors If true, deep errors while be returned too
* @return {this}
*/
schema(schema: Validator, { returnErrors }?: {
returnErrors?: boolean | undefined;
}): this;
/**
* Force any keys, to be the only one present in the object
* (exclusive relationships)
* oneIsRequired is false by default
*
* @param {mixed} params
* @return {this}
*/
oneOf(...params: string[]): this;
oneOf(oneIsRequired: boolean, ...params: string[]): this;
/**
* Force all keys to be mutually required. If one is presents, all are required. Pass if none are present.
*
* @param {...string} keys
* @return {this}
*/
allOf(...keys: string[]): this;
/**
* Force one or many keys to be present
*
* @param {...string} keys
* @return {this}
*/
anyOf(...keys: string[]): this;
}
declare const def: {
Class: typeof TypeObject;
messages: LangList;
};
export default def;