Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests around object circular reference issue #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nathandem
Copy link

@nathandem nathandem commented Apr 11, 2020

Hi, while trying to find out about where the casting bug comes from I noticed that there's an issue around object circular reference. It was hidden until now because the returned values where not inspected.

This issue seems less of a priority than the other one, but I report it anyway :)

@vlucas
Copy link
Owner

vlucas commented Apr 13, 2020

Thank you for the report and the failing test. This helps me look into it easier :)

@restyler
Copy link

restyler commented Oct 31, 2020

I can confirm that validateSync() modifies the validated object if it has nesting, adding Circular ref.
I had to use JSON.parse(JSON.stringify(data)) to do deep clone of input and prevent it.
image

const schema = v.object({
    "search": v.string().required(),
    "list_date": v.object({
        min: v.string().regex(...regexDateRule)
    }),
    "sort": v.object({
        list_date: v.string().rule(...ascOrDescRule)
    })
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants