Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "util/createVerifiableClass"

Index

Type aliases

Functions

Type aliases

ES5Entity

ES5Entity: object

Type declaration

  • Optional _check?: function
  • Optional getDisplayName?: function
      • (): string
      • Returns string

  • Optional getInitialOptions?: function
      • (): any
      • Returns any

  • Optional getInitialRule?: function
      • (): any
      • Returns any

  • Optional getRuleString?: Function
  • Optional getTypeName?: Function
  • Optional toString?: Function

Functions

createVerifiableClass

  • createVerifiableClass<Result, Rule, Options>(entity?: ES5Entity, __namedParameters?: object): function
  • Creates a verifiable Class.

    const age = createVerifiableClass({
      _check(req) {
        return integer._check(req)
      },
      getDisplayName() {
        return 'Age'
      },
      getInitialRule() { return null },
      getInitialOptions() { return null }
    })
    
    age().ok(22) === true
    age().ok('22') === false
    age().getTypeName() === 'Age'
    age().toString() === 'Age()'
    
    // es6 inheritance
    class Age extends Verifiable {
       _check() {
         return integer._check(req)
       }
       static displayName = 'Age'
       constructor(rule, options) {
         super(rule, options)
         this.rule = null
         this.options = null
       }
    }
    
    const age = funcify(Age)
    const age() instanceof Age // true
    new Age() instanceof Age // true
    
    constructify(age) === Age // true
    

    Type parameters

    • Result

    • Rule

    • Options

    Parameters

    • Default value entity: ES5Entity = {}
    • Default value __namedParameters: object = {}

    Returns function

      • (rule?: Rule, options?: Options): Result
      • Parameters

        • Optional rule: Rule
        • Optional options: Options

        Returns Result

Generated using TypeDoc