File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33class HtmlValidator < ActiveModel ::EachValidator
44 def validate_each ( record , attribute , value )
55 return if value . blank?
6- record . errors . add ( attribute , I18n . t ( 'html_validator.invalid_markup' ) ) unless valid_html? ( value )
6+ errors = html_errors ( value )
7+ unless errors . empty?
8+ record . errors . add ( attribute , I18n . t ( 'html_validator.invalid_markup' , error : errors . first . to_s ) )
9+ end
710 end
811
912 private
1013
11- def valid_html? ( str )
12- Nokogiri ::HTML . fragment ( str ) . to_s == str
14+ def html_errors ( str )
15+ fragment = Nokogiri ::HTML . fragment ( str )
16+ fragment . errors
1317 end
1418end
Original file line number Diff line number Diff line change 638638 one : Something isn't quite right yet! Please review the error below
639639 other : Something isn't quite right yet! Please review %{count} errors below
640640 html_validator :
641- invalid_markup : contains invalid HTML markup
641+ invalid_markup : ' contains invalid HTML markup: %{error} '
642642 identity_proofs :
643643 active : Active
644644 authorize : Yes, authorize
You can’t perform that action at this time.
0 commit comments