lib/fanforce/validations/validations.rb in fanforce-validations-0.4.0 vs lib/fanforce/validations/validations.rb in fanforce-validations-0.4.1
- old
+ new
@@ -75,19 +75,17 @@
def validates_format_of_external_id(*args)
_external_id = args.first
opts = extract_options!(args).merge(:field => :_external_id)
params = extract_validation_params(opts)
- if is_present?(_external_id) and !_external_id.is_a?(String)
- opts[:message] = "if included, _external_id must be a string not a #{_external_id.class.name}"
- elsif !_external_id.nil? and _external_id.include?('/')
- opts[:message] = '_external_id cannot contain forward slashes (/)'
+ if is_present?(_external_id) and _external_id.include?('/')
+ opts[:message] = '_external_id contains one or more forward slashes (/), which is not allowed'
else
return true
end
- error = format_validation_error(opts, :_external_id, :invalid_data)
- raise_validation_errors(opts, [error], Fanforce::Error::RequestFailed)
+ errors = [format_validation_error(opts, :_external_id, :invalid_data)]
+ raise_validation_errors(opts, errors, Fanforce::Error::RequestFailed)
end
def format_validation_error(opts, fields, default_error_code=nil)
error = {
resource: is_present?(opts[:resource]) ? opts[:resource] : (self.class==Class ? self.name.demodulize.tableize.singularize : self.class.name.demodulize.tableize.singularize),
\ No newline at end of file