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 support for ajv-keywords #61

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

techntools
Copy link
Contributor

Useful to add custom validations.

I am using it in sequelize-to-openapi

@techntools
Copy link
Contributor Author

@wesleytodd PTAL

@wesleytodd
Copy link
Owner

Hey! Can you describe a bit what this does? I am not familiar with the lib so I would like to understand a bit more what this helps folks do before taking on the additional dep.

index.js Show resolved Hide resolved
@wesleytodd
Copy link
Owner

I am going to mark this as approved since it requires it to run CI for first time contributors, but I still would like to hear more about what this provides functionality wise, and maybe even ask that we write slightly more docs on it since that package doesn't even have a good description in it's readme.

wesleytodd
wesleytodd previously approved these changes Jul 11, 2024
@techntools
Copy link
Contributor Author

techntools commented Jul 12, 2024

@wesleytodd

Lets say you have a following json schema definition:

{
    type: 'object',
    properties: {
        name: {
            type: 'string',
            pattern: '^[a-zA-Z]$'
        }
    }
}

But json schema does not support flags such as i, g, etc.

With ajv-keywords, you can use custom keyword like regexp to get over that limitation:

{
    type: 'object',
    properties: {
        name: {
            type: 'string',
            regexp: {
                pattern: '^[a-z]$',
                flags: 'i'
            }
        }
    }
}

@wesleytodd
Copy link
Owner

Ah, interesting and for sure useful. Does this then also hook into the validation so that works correctly? Sorry for the niave questions here, but I think that this would be great to add to your docs if that is something you could do. Also, I think now that I have approved, if you push again it should re-triger the CI.

@techntools
Copy link
Contributor Author

@wesleytodd

It does participate in the validation

I have added an example as well with validPath()

@techntools
Copy link
Contributor Author

@wesleytodd

I apologise that your approval got dismissed as I forced pushed to my branch.

Added more test to show that query param can be validated with ajv-keywords

wesleytodd
wesleytodd previously approved these changes Jul 15, 2024
Copy link
Owner

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New approval, but I think maybe the GH feature here is broken because what use is it if a new push doesn't start triggering the ci? So if this doesn't work I might go ahead and change the setting on the repo.

@wesleytodd
Copy link
Owner

I updated the CI, I think if you rebase your PR it might fix the fact that it wont run for you as a new contributor.

@techntools
Copy link
Contributor Author

@wesleytodd

All checks are passed

Thanks for updating the CI.

Please approve once again.

@wesleytodd wesleytodd merged commit 62a0c58 into wesleytodd:main Jul 15, 2024
6 checks passed
@wesleytodd
Copy link
Owner

published as 1.1.0

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.

2 participants