Initial commit

This commit is contained in:
Yaser
2026-08-13 19:56:46 +03:30
commit de1d57a67b
474 changed files with 43185 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
# Data json validation
class DataIsJsonValidator < ActiveModel::EachValidator
def validate_each(record, attribute, data)
return if data.nil?
unless validate_data_is_json!(data)
record.errors.add(attribute, :invalid_format, message: 'data is not json compatible string')
end
end
def validate_data_is_json!(data)
begin
JSON.parse(data)
true
rescue JSON::ParserError => e
false
end
end
end