Skip to main content
Module

x/oridune_validator/mod.ts>BaseValidator

A powerful typescript compatible/zod alternative schema validator.
Go to Latest
class BaseValidator
Re-export
import { BaseValidator } from "https://deno.land/x/oridune_validator@v0.2.37/mod.ts";

Constructors

new
BaseValidator(type: ValidatorType, options: IBaseValidatorOptions)

Type Parameters

Type
Input
Output

Properties

protected
CustomValidators: TCustomValidator<any, any>[]
protected
DeepCasted: boolean
protected
DeepPartialed: boolean
protected
optional
Description: string
protected
Exception: ValidationException
protected
optional
Options: any
protected
optional
Sample: any
protected
Type: ValidatorType

Methods

protected
_resolveErrorMessage(message: TErrorMessage | undefined, defaultMessage: string)
protected
_toSample(_options?: ISampleDataOptions): Input

Adds a stop point to the validation if there was an error occured on the current validator.

Provide a custom method for validation.

describe(description: string)

Add a description for the JSON schema.

sample(sample: any)

Add a sample for the Sample data.

test(input?: any, options?: IValidationOptions)

Tries to execute the validation chain and returns a boolean value based on the result.

Adds a stop point to the validation if there was an error occured on the current validator.

Generates a JSON schema based on your validation schema.

Generates a Sample data based on your validation schema.

try(input?: any, options?: IValidationOptions)

Tries to execute the validation chain and if there is an error, it will not be thrown but instead will be returned.

validate(input?: any, options?: IValidationOptions): Promise<Output>

Executes the validation chain.

Static Methods

resolveValidator<V extends BaseValidator<any, any, any>>(validator: any): V