fy (version 0.1.0)

validate_fys_permitted: Verifying validity of financial years

Description

Many functions expect financial years. Determining that they are validly entered is often quite computationally costly, relative to the core calculations. These internal functions provide mechanisms to check validity quickly, while still providing clear, accurate error messages.

Usage

validate_fys_permitted(to_verify, permitted_fys = NULL, min.yr = NULL,
  max.yr = NULL, deparsed = deparse(substitute(to_verify)),
  allow.projection = TRUE,
  earliest_permitted_financial_year = "earliest permitted financial year",
  latest_permitted_financial_year = "latest permitted financial year")

Arguments

to_verify

A user-provided value, purporting to be character vector of financial years.

permitted_fys

A character vector of valid financial years.

min.yr, max.yr

Integers specifying the range of to_verify. If NULL, no restriction on the upper or lower bound of the range.

deparsed

A string indicating the argument that the user provided. Should generally be provided explicitly as the default is unlikely to be user-friendly.

allow.projection

If FALSE emit a different error message.

earliest_permitted_financial_year, latest_permitted_financial_year

Text for earliest/latest permitted financial year when min.yr/max.yr condition is violated.

Value

If to_verify contains valid financial years they are returned all in the form 2013-14. If they were already in that form, they obtain the following attributes:

fy_all_fy

TRUE if all the financial years are valid.

fy_min_yr

An integer, the earliest year ending in to_verify.

fy_max_yr

An integer, the latest year ending in to_verify.