Skip to content

feat: #1087 create validation helper utilities - #1119

Merged
Eniola3321 merged 1 commit into
ANYTECHS:mainfrom
Adedayo-Data:feat/1087-validation-helpers
Sep 30, 2026
Merged

Eniola3321 merged 1 commit into
ANYTECHS:mainfrom
Adedayo-Data:feat/1087-validation-helpers

Conversation

@Adedayo-Data

Copy link
Copy Markdown
Contributor

PR 4 — feat/1087-validation-helpers → main

Title: feat: #1087 [Validators] Create Validation Helper Utilities

Description:

Closes #1087

Summary

Introduces a new validation_helpers module containing shared, reusable validation utilities for common operations across the contract. Eliminates duplicated validation logic and ensures all modules use the canonical error definitions from types::Error.

Changes

  • validation_helpers.rs — new module with:
    • require_non_zero_u32 — rejects zero u32 values (InvalidConfig)
    • validate_basis_points — validates BPS within configurable max (InvalidBasisPoints)
    • validate_within_range_u32 — validates inclusive numeric range (InvalidConfig)
    • validate_address_not_contract — rejects the contract's own address (InvalidAddress)
    • validate_address_not_blacklisted — integrates with blacklist module (InvalidAddress)
    • validate_not_zero_address — rejects None optional addresses (InvalidAddress)
    • validate_string_non_empty — rejects empty strings (InvalidURI)
    • validate_string_max_len — enforces maximum string size (MetadataSizeTooLarge)
    • validate_uri_scheme — enforces https://, ipfs://, ar:// protocols (UnsupportedProtocol)
    • validate_token_exists — checks token ownership record existence (TokenNotFound)

Acceptance Criteria

  • Support reusable validation helpers
  • Avoid duplicated validation logic
  • Integrate with contract error definitions (types::Error)
  • Add helper tests

- Add require_positive_u32 for non-zero u32 checks
- Add validate_basis_points with configurable max BPS
- Add validate_range_u32 for inclusive numeric range validation
- Add validate_positive_i128 for positive price/amount checks
- Add validate_not_contract_address to reject self-address inputs
- Add validate_not_blacklisted integrating with blacklist module
- Add validate_option_address for Option<Address> presence checks
- Add validate_non_empty_string for empty string rejection
- Add validate_string_length for max-size enforcement
- Add validate_uri_protocol for https/ipfs/ar scheme validation
- Add validate_token_id_exists using token_owner_storage
- All helpers use canonical Error definitions from types.rs
- Register pub mod validation_helpers in lib.rs
- Add comprehensive unit tests for all helpers
@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Adedayo-Data Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Eniola3321
Eniola3321 merged commit 2cf4422 into ANYTECHS:main Sep 30, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Validators] Create Validation Helper Utilities

2 participants