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

Guards error #1

Open
RonanzinDev opened this issue Aug 23, 2021 · 0 comments
Open

Guards error #1

RonanzinDev opened this issue Aug 23, 2021 · 0 comments

Comments

@RonanzinDev
Copy link

I'm following the rest code example, and I'm having this error in the guards:
Sem título

I already implemented check(), but the error continues

module Rest
  module Guard
    class UserValidator < Shivneri::Guard
      @[Inject("as_body")]
      @[BodySameAs("UserController", "add_user")]
      def check(user)
        err_message = validate user
        if (err_message.size > 0)
          return text_result(err_message, 400)
        end
      end

      def validate(user)
        if (user.name.size < 5)
          return "name should be minimum 5 characters"
        elsif (!["male", "female"].include? user.gender)
          return "gender should be either male of female"
        end
        return ""
      end
    end
  end
end
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

1 participant