Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Cannot read property 'existyStrict' of undefined #255

@smk005

Description

@smk005

Prerequisites

Hi Team, I am getting the following issue as shown below for extend sample.

[
{
message: "Cannot read property 'existyStrict' of undefined",
validation: 'ENGINE_EXCEPTION',
field: 'start_time'
}
]
How can I fix. Please help. Thank you in advance for your support. Really very awesome and helpful validation library.

Package version

v7.4.4

Node.js and npm version

12.11.1

Sample Code (to reproduce the issue)

const { validate, configure, validateAll, extend } = require('indicative/validator');
const { getValue, skippable } = require('indicative-utils');

const schema = {
username: 'required|alpha',
start_time: 'required|time',
//password: 'required|min:4|max:40',
}

const data = {
username: 'test',
start_time:'0er'
}

const timeRegex = /([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?/;

extend('time', {
async: false,

validate (data, field, args) {
    const fieldValue = getValue(data, field)
    if (skippable(fieldValue)) {
    return true
    }

    return timeRegex.test(fieldValue)
}
});

validate(data, schema, {'start_time.required':'start_time is required','start_time.time':'invalid start time format'}, {
    existyStrict: false,
    removeAdditional: false
  })
.then(console.log)
.catch(console.error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions