lib/syntax_file/controller.rb
def validate_metadata (check = {})
    bad_metadata('no variables') if @variables.empty?

    if @rectangularize
        msg = 'the rectangularize option requires data_structure=hier'
        bad_metadata(msg) unless @data_structure == 'hier'
    end

    if @data_structure == 'hier' or @select_vars_by_record_type
        bad_metadata('no record types') if @record_types.empty?

        msg = 'record types must be unique'
        bad_metadata(msg) unless rec_type_lookup_hash.keys.size == @record_types.size

        msg = 'all variables must have a record type'
        bad_metadata(msg) unless @variables.find { |var| var.record_type.length == 0 }.nil?

        msg = 'with no common variables, every record type needs at least one variable ('
        if @variables.find { |var| var.is_common_var }.nil?
            @record_types.each do |rt|
                next if get_vars_by_record_type(rt).size > 0
                bad_metadata(msg + rt + ')')
            end
        end
    end

    if @data_structure == 'hier'
        bad_metadata('no record type variable') if record_type_var.nil?
    end

    return if check[:minimal]

    @variables.each do |v|
        v.start_column     = v.start_column.to_i
        v.width            = v.width.to_i
        v.implied_decimals = v.implied_decimals.to_i
        bad_metadata("#{v.name}, start_column"    ) unless v.start_column     >  0
        bad_metadata("#{v.name}, width"           ) unless v.width            >  0
        bad_metadata("#{v.name}, implied_decimals") unless v.implied_decimals >= 0
    end
end
def validate_metadata (check = {})
    bad_metadata('no variables') if @variables.empty?

    if @rectangularize
        msg = 'the rectangularize option requires data_structure=hier'
        bad_metadata(msg) unless @data_structure == 'hier'
    end

    if @data_structure == 'hier' or @select_vars_by_record_type
        bad_metadata('no record types') if @record_types.empty?

        msg = 'record types must be unique'
        bad_metadata(msg) unless rec_type_lookup_hash.keys.size == @record_types.size

        msg = 'all variables must have a record type'
        bad_metadata(msg) unless @variables.find { |var| var.record_type.length == 0 }.nil?

        msg = 'with no common variables, every record type needs at least one variable ('
        if @variables.find { |var| var.is_common_var }.nil?
            @record_types.each do |rt|
                next if get_vars_by_record_type(rt).size > 0
                bad_metadata(msg + rt + ')')
            end
        end
    end

    if @data_structure == 'hier'
        bad_metadata('no record type variable') if record_type_var.nil?
    end

    return if check[:minimal]

    @variables.each do |v|
        v.start_column     = v.start_column.to_i
        v.width            = v.width.to_i
        v.implied_decimals = v.implied_decimals.to_i
        bad_metadata("#{v.name}, start_column"    ) unless v.start_column     >  0
        bad_metadata("#{v.name}, width"           ) unless v.width            >  0
        bad_metadata("#{v.name}, implied_decimals") unless v.implied_decimals >= 0
    end
end
Before generating syntax, run a sanity check on the metadata.