rules repository

A-3150 Avoid a null entry on required LOV items and Interactive Grid columns.

Severity Info SQL-based Test Free New

Reason

A required LOV item or Interactive Grid column that also offers a null entry lets users pick a value that is always rejected on save. The empty choice looks valid and only fails at validation time.

Turn off Display Null Value in the LOV settings, or remove Value Required if an empty value is a valid state. If possible, also set a default value when one fits the majority of cases, so new rows start with a sensible choice.

Some teams keep the null entry on purpose as a prompt such as "- Select -", so that new rows do not silently get the first value. A null entry whose text matches the parameter ApexLovNullTextPattern (by default text between dashes) is accepted and not reported; adjust the pattern to your convention, or disable the rule.

Example

Non-Compliant Example

page 10 (
    // ...
    region orders (
        name: Orders
        // ...
        advanced {
            htmlDomId: orders
        }

        column STATUS (
            type: selectList
            // ...
            lov {
                type: sharedComponent
                lov: @order-status
                // no displayNullValue: defaults to true
            }
            validation {
                valueRequired: true
            }
        )
    )

    region order-form (
        name: Order
        // ...
    )

    pageItem P10_STATUS (
        type: selectList
        layout {
            region: @order-form
            // ...
        }
        lov {
            type: sharedComponent
            lov: @order-status
            // no displayNullValue: defaults to true
        }
        validation {
            valueRequired: true
        }
    )
)
Issues
LineColumnMessage
1313Required LOV column offers a null entry.
359Required LOV item offers a null entry.

Compliant Solution - ★★★★★

page 10 (
    // ...
    region orders (
        name: Orders
        // ...
        advanced {
            htmlDomId: orders
        }

        column STATUS (
            type: selectList
            // ...
            lov {
                type: sharedComponent
                lov: @order-status
                displayNullValue: false
            }
            validation {
                valueRequired: true
            }
        )
    )

    region order-form (
        name: Order
        // ...
    )

    pageItem P10_STATUS (
        type: selectList
        layout {
            region: @order-form
            // ...
        }
        lov {
            type: sharedComponent
            lov: @order-status
            nullDisplayValue: "- Select -"
        }
        validation {
            valueRequired: true
        }
    )
)

Tests

Test SQL query

select aa.workspace || '.' || aa.alias || '.' || c.page_id || '.' || coalesce(r.static_id, to_char(r.region_id)) || '.' || c.name as identifier,
       'Column ' || c.name || ' of Interactive Grid ' || c.region_name || ' on page ' || c.page_id || ' of app ' || aa.alias
         || ' in ' || aa.workspace || ' is required but its list of values offers a null entry.' as message
  from apex_appl_page_ig_columns c
  join apex_application_page_regions r
    on r.application_id = c.application_id
       and r.region_id = c.region_id
  join apex_applications aa
    on aa.application_id = c.application_id
       and aa.workspace = c.workspace
 where aa.workspace in (#ApexWorkspaces#)
   and c.is_required = 'Yes'
   and c.lov_display_null = 'Yes'
   and not regexp_like(coalesce(c.lov_null_text, ' '), #ApexLovNullTextPattern#, 'i')
   and exists (select 1
                 from apex_appl_page_igs ig
                where ig.application_id = c.application_id
                  and ig.region_id = c.region_id
                  and ig.is_editable = 'Yes')
union all
select aa.workspace || '.' || aa.alias || '.' || i.page_id || '.' || i.item_name as identifier,
       'Item ' || i.item_name || ' on page ' || i.page_id || ' of app ' || aa.alias || ' in ' || aa.workspace
         || ' is required but its list of values offers a null entry.' as message
  from apex_application_page_items i
  join apex_applications aa
    on aa.application_id = i.application_id
       and aa.workspace = i.workspace
 where aa.workspace in (#ApexWorkspaces#)
   and i.is_required = 'Yes'
   and i.lov_display_null = 'Yes'
   and not regexp_like(coalesce(i.lov_null_text, ' '), #ApexLovNullTextPattern#, 'i')

Test results

IdentifierMessageMigration
WORKSPACE.CUSTOMERS.10.P10_STATUSItem P10_STATUS on page 10 of app CUSTOMERS in WORKSPACE is required but its list of values offers a null entry.-
WORKSPACE.CUSTOMERS.10.orders.STATUSColumn STATUS of Interactive Grid Orders on page 10 of app CUSTOMERS in WORKSPACE is required but its list of values offers a null entry.-

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
ApexLovNullTextPatternRegex for null entry texts accepted as a prompt, e.g. - Select -^\s*-+.*-+\s*$
ApexWorkspacesComma-separated List of APEX workspaces owning APEX applications to check.dblinter, dbl_gui

References