def validate(form)
      fields = fields_to_validate
      return form  if fields.empty?

      validate_presence_of_required_fields form, fields

      fields.each_pair do |key, opts|
        next  if !form.has_key?(key) || form[key].nil?

        form[key] = validate_re key, form[key], opts
        form[key] = validate_iso_date key, form[key], opts
        form[key] = validate_ipaddr key, form[key], opts
      end

      form
    end
def validate(form)
      fields = fields_to_validate
      return form  if fields.empty?

      validate_presence_of_required_fields form, fields

      fields.each_pair do |key, opts|
        next  if !form.has_key?(key) || form[key].nil?

        form[key] = validate_re key, form[key], opts
        form[key] = validate_iso_date key, form[key], opts
        form[key] = validate_ipaddr key, form[key], opts
      end

      form
    end
Validates specified `form` with `required` and `optional` fields.
 @param [Hash] form Form to validate.
 @return [Hash] Updated form.
 @raise ContractError