lib/yaml-validator.rb in yaml-validator-0.1.3 vs lib/yaml-validator.rb in yaml-validator-0.1.4
- old
+ new
@@ -1,9 +1,10 @@
require 'yaml'
require 'yaml-validator/version'
require_relative './helpers'
require_relative './pluralization-validator'
+require_relative './sanitized-html-validator'
class YamlValidator
def initialize(root_path, options = {})
@options = options
@@ -54,10 +55,11 @@
yaml_object = Helpers.normalize_yaml(yaml_object)
errors += validate_yaml_object('', yaml_object)
if @options[:show_missing]
errors.concat find_missing_translations(yaml_object)
errors.concat find_missing_pluralizations(filename, yaml_object)
+ errors.concat find_unsanitized_html(filename, yaml_object)
end
errors.map { |err| "#{filename}: #{err}" }
end
@@ -180,8 +182,12 @@
end
def identify_variables(string)
string.scan(/%\{([^}]+)\}/).map(&:first)
end
-
+
+ def find_unsanitized_html(filename, yaml_object)
+ language = File.basename(filename, '.*')
+ SanitizedHtmlValidator.validate(language, yaml_object)
+ end
end