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

[Question] How to use Custom Validator? #772

Open
Kyokatarz opened this issue Aug 30, 2022 · 1 comment
Open

[Question] How to use Custom Validator? #772

Kyokatarz opened this issue Aug 30, 2022 · 1 comment

Comments

@Kyokatarz
Copy link

Kyokatarz commented Aug 30, 2022

Hi,

How do I use the defined Custom Validator?
For example if I define

class NameValidator < ApiPie::Validator::BaseValidator
  (...defined here)
end

How do I use NameValidator then?

I tried calling in my route controller:

class Api::V2::NameController < Api::V2::ApplicationController
  api :PUT, '/v2/name', 'Get user name'
  param :name, NameValidator, desc: "Name", required: true
  param_group :defaults, Api::V2::ApplicationController
(.......)

I get this error
uninitialized constant Api::V2::NameController::NameValidator

Is this written in the code somewhere? Or am I using it wrong?

@mathieujobin
Copy link
Collaborator

I use param :useful_id, :number, 'ID/s of something useful' in the controller

and automatically, it loads up Apipie::Validator::NumberValidator

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

No branches or pull requests

2 participants