Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Validator

Create new validation functions

- Validator:
    lowerCheck: |
      (actual, expected) => {
        if(actual?.toLowerCase() !== expected?.toLowerCase()) assert.fail(actual, expected, 'String lower not match', 'toLowerCheck')
      }
    chaiTest: |
      utils.addChainableMethod(chai.Assertion.prototype, 'chaiTest', function (str) {
        var obj = utils.flag(this, 'object');
        new chai.Assertion(obj).to.be.equal(str);
      });
###
- Vars:
    obj: { name: Name 1 }
 
- Validate:
    title: Validate object schema which use builtin system
    func: schema
    args: 
      - ${obj}
      - { "type": "array" }
 
- Echo: Test custom validation
- Validate:
    title: check name ignore case lower
    func: lowerCheck
    args:
      - ${obj.name}
      - name 12
- Validate:
    title: check name ignore case upper
    func: upperCheck
    args:
      - ${obj.name}
      - name 1

- Echo: Use chaijs (assert, expect) to validate (https://www.chaijs.com/api/bdd/)
 
- Validate:
    title: Check name
    func: expect.to.equal
    args:
      - ${obj.name}
      - Name 1
- Validate:
    title: check 2 objects equals
    func: expect.to.deep.equal
    args:
      - ${obj}
      - {name: 'Name 1'}
- Validate:
    title: Check object got value
    func: assert.isOk
    args:
      - ~
- Validate:
    title: Check chaiTest
    func: expect.to.be.chaiTest
    args:
      - Test

Hierarchy

  • Tag
    • Validator

Index

Constructors

constructor

Properties

async

async: boolean

Run async

disabled

disabled: boolean

Ignore this, not run

ignoreError

ignoreError: boolean

Keep run the next when got error

slient

slient: boolean

Not show log

testIt

testIt: boolean

Only allow run it then ignore others which not set testIt or set it to false

title

title: string

Step title

vars

vars: any

Declare global variable