types-check

Validate R function inputs with standalone check_* helper files.

224|52|Updated Jun 10, 2020
One-click install
npx skills add https://github.com/r-lib/cpp11 --skill types-check
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: types-check
Source: https://github.com/r-lib/cpp11/tree/main/.claude/skills/tidy-argument-checking
Command: npx skills add https://github.com/r-lib/cpp11 --skill types-check

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a centralized, opinionated approach to validating function inputs in R by using a standalone file of check_* helpers. It helps packages enforce consistent, clear error messages at the boundary between user code and internal logic, reducing boilerplate.

Core Features & Use Cases

  • Scalar validators: check_string, check_number_whole, check_name, check_bool, check_number_decimal
  • Vector validators: check_character, check_logical, check_data_frame, and nuanced NA handling with allow_na
  • Support for NULL through allow_null, and guidance on warning about invalid inputs at the entry point
  • Clear guidance on wrapping existing check_ functions and propagating caller context to preserve accurate error reporting

Quick Start

Use the tidy-argument-checking approach to add a standalone file of check_* helpers to your package, then validate inputs at the start of exported functions.

Frequently Asked Questions about types-check

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate function inputs in R with consistent error messages?

To validate function inputs in R with consistent error messages, use a standalone file of check_* helpers like check_string and check_data_frame at the start of exported functions, enforcing early boundary validation and reducing boilerplate code.

What is the tidy-argument-checking approach for R package development?

The tidy-argument-checking approach for R package development involves adding a standalone file of scalar and vector check_* helpers to validate inputs at the entry point of exported functions, ensuring clear and consistent error reporting.

How do I check if an R function input is a string or a whole number?

You can check if an R function input is a string or a whole number by applying scalar validators like check_string and check_number_whole, which verify input types and return standardized error messages if validation fails.

Can I allow NULL or NA values when validating data frames in R?

Yes, you can allow NULL or NA values when validating data frames in R by using the allow_null and allow_na arguments within vector validators like check_data_frame to handle nuanced missing data scenarios.

How do I propagate caller context when wrapping input validation checks in R?

To propagate caller context when wrapping input validation checks in R, pass the arg and call contexts through your custom check_ functions, preserving accurate error reporting back to the original user code boundary.

Does standalone input validation require external dependencies for R packages?

No, standalone input validation does not require external dependencies for R packages because the check_* helpers are implemented within a single standalone file, keeping your package lightweight and modular without adding external dependencies.