Added
New Validation Functions
-
isNumeric()- Validates if a string represents a numeric value (integer or decimal)- Handles positive and negative integers (
42,-17) - Supports decimal numbers (
3.14,-0.5) - Automatic whitespace trimming
- Rejects empty strings,
Infinity, and scientific notation - Bundle size: 122 bytes gzipped
- Handles positive and negative integers (
-
isAlphanumeric()- Validates if a string contains only alphanumeric characters (a-z, A-Z, 0-9)- Strict ASCII validation (no Unicode, special characters, or whitespace)
- Perfect for username validation, identifiers, and tokens
- Bundle size: 88 bytes gzipped
-
isUUID()- Validates if a string is a valid UUID in standard 8-4-4-4-12 format- Supports all UUID versions (v1-v5)
- Accepts NIL UUID (
00000000-0000-0000-0000-000000000000) - Case-insensitive validation
- Bundle size: 89 bytes gzipped
Branded Type Integration
Full type-safe handling for all three validation functions:
- New branded types:
NumericString,AlphanumericString,UUID - Type guards:
isValidNumeric(),isValidAlphanumeric(),isValidUUID() - Builder functions:
toNumericString(),toAlphanumericString(),toUUID() - Assertion functions:
assertNumericString(),assertAlphanumericString(),assertUUID() - Unsafe casts:
unsafeNumericString(),unsafeAlphanumericString(),unsafeUUID() - Zero runtime overhead - type safety enforced at compile time
CLI Support
All three functions available via `nano-string` command:
- `nano-string isNumeric "42"`
- `nano-string isAlphanumeric "user123"`
- `nano-string isUUID "550e8400-e29b-41d4-a716-446655440000"`
Documentation
- Updated function count from 48 to 51 utilities
- Added comprehensive JSDoc documentation with real-world usage examples
- Updated README with function descriptions, examples, and bundle sizes
- Regenerated bundle size and performance benchmark data
📦 Installation: `npm install nano-string-utils`
📚 Documentation: https://zheruel.github.io/nano-string-utils/