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

How to return error when the vlaue of field is '' and set the field as required #2430

Closed
nick121212 opened this issue May 10, 2024 · 2 comments

Comments

@nick121212
Copy link

What version of Ajv you are you using?

latest

What problem do you want to solve?

const schema = { type: 'object', properties: { name: { type: 'string', title: 'Name', minLength: 1, }, }, required: ['name'], }

`
const valid = ajv.compile(schmea)({name:''});

// valid is true

// Can i get required error when name is ''?

`

What do you think is the correct solution to problem?

can we add some option to change the behavior?

Will you be able to implement it?

@jasoniangreen
Copy link
Collaborator

Hi @nick121212, can you replicate this in Runkit (you can clone this https://runkit.com/esp/ajv-issue)?

I tried running this locally and it works as expected, i.e. valid is false for an empty string.

@jasoniangreen
Copy link
Collaborator

Closing as I have been unable to repro. Happy to reopen if you can provide a runkit link demonstrating the issue.

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

No branches or pull requests

2 participants