Summary
Introduce consistent validation for unrecognized keyword arguments in the options-bearing packages, while preserving the existing options-object call path.
This is intentionally deferred from PR #27 because silently ignoring unknown keywords is existing behavior in published packages. The change should be designed and released as a coordinated compatibility/breaking-change effort rather than altering only cpf-utilities.
Rationale
Calls such as a misspelled keyword can currently be silently ignored when keywords are normalized into option overrides. Rejecting those keys will surface API misuse at the call site, but doing so in only one package would make behavior inconsistent across the monorepo and may break existing consumers.
Affected packages
cnpj-fmt
cnpj-gen
cnpj-val
cnpj-utilities
cpf-fmt
cpf-gen
cpf-val
cpf-utilities
br-utilities
Required behavior
- Validate unknown keys only when the caller is using the keyword-argument path; do not apply this validation merely because an
options instance argument was supplied.
- Treat an unrecognized key as invalid even when its value is
nil.
- Raise the package-specific custom API-misuse error that inherits from
ArgumentError (not native ArgumentError directly), following each package's error hierarchy and marker-module conventions.
- Keep recognized keyword behavior unchanged.
Acceptance criteria
Backlinks
Summary
Introduce consistent validation for unrecognized keyword arguments in the options-bearing packages, while preserving the existing
options-object call path.This is intentionally deferred from PR #27 because silently ignoring unknown keywords is existing behavior in published packages. The change should be designed and released as a coordinated compatibility/breaking-change effort rather than altering only
cpf-utilities.Rationale
Calls such as a misspelled keyword can currently be silently ignored when keywords are normalized into option overrides. Rejecting those keys will surface API misuse at the call site, but doing so in only one package would make behavior inconsistent across the monorepo and may break existing consumers.
Affected packages
cnpj-fmtcnpj-gencnpj-valcnpj-utilitiescpf-fmtcpf-gencpf-valcpf-utilitiesbr-utilitiesRequired behavior
optionsinstance argument was supplied.nil.ArgumentError(not nativeArgumentErrordirectly), following each package's error hierarchy and marker-module conventions.Acceptance criteria
nilvalue raises the appropriate package-specific customArgumentError.optionsinstance continues to follow its existing contract without keyword-key validation being incorrectly applied.ArgumentErrorinheritance and packageErrormarker inclusion.nilkeywords, unknownnilkeywords, andoptions-instance behavior for every affected package.Backlinks
cpf-utils] Create package to consolidate itilities for CPF #27: [cpf-utils] Create package to consolidate itilities for CPF #27cpf-utils] Create package to consolidate itilities for CPF #27 (comment)