Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

Protected _rules

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

_type

_type: string

Methods

alphanum

beginsWith

between

check

custom

email

endsWith

  • Check ending of a string

    import yxc from "@dotvirus/yxc"
    
    yxc.string().endsWith("pusher").validate("test") // -> Fails
    yxc.string().endsWith("pusher").validate("Squarepusher") // -> OK
    

    Parameters

    • substr: string

    Returns StringHandler

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: string[]

    Returns StringHandler

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: string

    Returns StringHandler

len

length

match

max

min

notEmpty

nullable

numeric

optional

pattern

prefix

regex

rule

startsWith

  • Check beginning of a string

    import yxc from "@dotvirus/yxc"
    
    yxc.string().startsWith("pusher").validate("Squarepusher") // -> Fails
    yxc.string().startsWith("Squ").validate("Squarepusher") // -> OK
    

    Parameters

    • substr: string

    Returns StringHandler

suffix

test

use

validate

Generated using TypeDoc