Options
All
  • Public
  • Public/Protected
  • All
Menu

Validate any value, use rules to narrow it down

Hierarchy

Index

Constructors

constructor

Properties

Protected _rules

_rules: Rule<any>[] = ...

_type

_type: any

Methods

check

custom

enum

  • Only allows a selection of values

    import yxc from "@dotvirus/yxc"
    
    const allowedValues = ["test", "test2", "test3"]
    
    yxc.string().enum(allowedValues).validate("test") // -> OK
    yxc.string().enum(allowedValues).validate("asdasd") // -> Fails
    

    Parameters

    • values: any[]

    Returns AnyHandler

eq

equal

equals

  • Only allows a certain value Value is checked using strict equality (===)

    import yxc from "@dotvirus/yxc"
    
    yxc.string().equals("test").validate("test") // -> OK
    yxc.string().equals("test").validate("test2") // -> Fails
    

    Parameters

    • expected: any

    Returns AnyHandler

falsy

nullable

optional

rule

test

truthy

use

validate

Generated using TypeDoc