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 ability to markup validator description #282

Merged
merged 1 commit into from
Sep 8, 2014

Conversation

exAspArk
Copy link
Contributor

Hi!
I'm using config.markup = Apipie::Markup::Markdown.new and I have my custom validator:

class Apipie::Validator::StringQueryValidator < Apipie::Validator::BaseValidator
  def initialize(param_description, argument, options)
    super(param_description)
  end

  def validate(value)
    !!(value =~ /^[^&*\/\^]+$/)
  end

  def self.build(param_description, argument, options, block)
    if options[:validator] == :query
      self.new(param_description, argument, options)
    end
  end

  def description
    'Must have any characters except: `/` `&` `^` `*`'
  end
end

I'd like to make this description highlighted 😺

@@ -17,7 +17,7 @@
<%= param[:description].html_safe %>
<% unless param[:validator].blank? %>
<br>
Value: <%= param[:validator] %>
Value: <%= param[:validator].html_safe %>
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we shouldn't have the Apipie.markup_to_html(params[:validator]).html_safe here. The reasons:

  1. through the JSON api that apipie provides, I would expect the non-html version
  2. when adding new validator, one would always need to not forget to wrap that into the Apipie.markup_to_html('...')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iNecas I agree. What about using markup_to_html in partials?

Copy link
Member

Choose a reason for hiding this comment

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

+1 on that

@exAspArk
Copy link
Contributor Author

@iNecas updated :)

@iNecas
Copy link
Member

iNecas commented Sep 8, 2014

Looks good, Thanks!

iNecas added a commit that referenced this pull request Sep 8, 2014
Add ability to markup validator description
@iNecas iNecas merged commit 1481a5b into Apipie:master Sep 8, 2014
@iNecas
Copy link
Member

iNecas commented Jan 7, 2015

I'm happy to announce that the new version 0.3.0 was released, including this change. Thanks for making that happen https://github.com/Apipie/apipie-rails/blob/master/CHANGELOG.md#v030

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