lib/yaml-validator.rb in yaml-validator-0.1.6 vs lib/yaml-validator.rb in yaml-validator-0.1.7
- old
+ new
@@ -51,16 +51,16 @@
errors = validate_root_language(yaml_object, File.basename(filename))
yaml_object = yaml_object[yaml_object.keys[0]]
yaml_object = Helpers.normalize_yaml(yaml_object)
errors += validate_yaml_object('', yaml_object)
- if @options.missing?
+ if @options[:missing]
errors.concat find_missing_translations(yaml_object)
errors.concat find_missing_pluralizations(filename, yaml_object)
end
- if @options.sanitize?
+ if @options[:sanitize]
errors.concat find_unsanitized_html(filename, yaml_object)
end
errors.map { |err| "#{filename}: #{err}" }
end
@@ -131,9 +131,31 @@
nil
end
end
def validate_item(full_key, value, is_pluralization = false)
+ errors = validate_item_vars(full_key, value, is_pluralization)
+ errors.concat validate_item_characters(full_key, value)
+ errors
+ end
+
+ def validate_item_characters(full_key, value)
+ bad_chars = '⏎'
+ bad_chars_found = []
+ bad_chars.each_char do |ch|
+ if value.include? ch
+ bad_chars_found << ch
+ end
+ end
+
+ if bad_chars_found.any?
+ return ["#{full_key}: bad characters (#{bad_chars_found.join(', ')} ) in '#{value}'"]
+ else
+ return []
+ end
+ end
+
+ def validate_item_vars(full_key, value, is_pluralization = false)
real_vars = get_key_en_vars(full_key)
if real_vars.nil?
if is_pluralization
return []
else