Skip to content

isJSON doesn't validate json-encoded strings #297

Open
@alust

Description

@alust
> import {Validator} from "class-validator";
{}
> const validator = new Validator();
undefined
> let json_str = JSON.stringify('abc');
undefined
> validator.isJSON(json_str);
false

However json-encoded objects and arrays are validated correctly:

> json_str = JSON.stringify({});
'{}'
> validator.isJSON(json_str);
true
> json_str = JSON.stringify([]);
'[]'
> validator.isJSON(json_str);
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions