Skip to content

A C++ library for validating user input, including numeric range checks, date validation, and safe string reading. It ensures robust and error-free input handling in console applications.

Notifications You must be signed in to change notification settings

AmrTamerTech/clsInput_Validation_Library-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ C++ Input Validation Library (clsInputValidate) ⚑

A lightweight and efficient C++ utility class designed to validate user input, ensuring data integrity and seamless error handling. This library provides robust number and date validation functions for console applications. πŸš€


🌟 Project Overview

The clsInputValidate class helps developers ensure that user input meets required constraints, preventing invalid entries and enhancing program reliability. It includes functionalities such as:

βœ”οΈ Numeric validation: Ensures input falls within a valid range.
βœ”οΈ Date validation: Checks if a date is valid and falls within a given range.
βœ”οΈ User input handling: Reads and processes numbers and strings safely.
βœ”οΈ Error handling: Prevents incorrect inputs and prompts re-entry.

This class is designed for C++ console-based applications that require user input validation.


✨ Features

πŸ”’ Numeric Validation

βœ… IsNumberBetween(Number, From, To): Checks if a number is within a specified range.
βœ… ReadNumber<T>(): Reads a number from user input and ensures validity.
βœ… ReadNumberBetween<T>(From, To): Reads a number and validates it against a given range.

πŸ“… Date Validation

βœ… IsDateBetween(Date, DateFrom, DateTo): Verifies if a date is within a given range.
βœ… IsValidDate(Date): Ensures that a given date is valid.

πŸ–ŠοΈ User Input Handling

βœ… ReadShortNumber(): Reads a short value from the user.
βœ… ReadIntNumber(): Reads an int value from the user.
βœ… ReadFloatNumber(): Reads a float value from the user.
βœ… ReadDoubleNumber(): Reads a double value from the user.
βœ… ReadString(): Reads and returns a string input from the user.


πŸš€ How It Works

πŸ”Ή Numeric Validation

  • Uses template functions for flexible number validation.
  • Ensures numbers fall within a valid range before returning them.

πŸ”Ή User Input Handling

  • Uses cin, cin.clear(), and cin.ignore() to manage incorrect inputs.
  • Prevents crashes by properly handling invalid input formats.

πŸ”Ή Date Handling

  • Utilizes the clsDate class to compare and validate date values.
  • Allows date range validation by checking if a date is between two others.

πŸ“š Potential Enhancements

πŸ›  Extended Error Handling: More detailed error messages for invalid input cases.
πŸ—„ Logging Support: Store incorrect attempts for debugging or analytics.
πŸ”„ Customizable Validation Rules: Allow developers to define custom validation rules dynamically.
🌎 Localization Support: Multi-language error messages for international applications.


βš™οΈ Technologies Used

  • Language: C++
  • Concepts: Template functions, Input handling, Error validation
  • Libraries: <iostream>, <string>, <limits>

🎯 Learning Outcomes

βœ”οΈ Robust input validation techniques
βœ”οΈ Template function usage for flexible validation
βœ”οΈ Error handling using input clearing and ignoring methods
βœ”οΈ Date validation with structured logic
βœ”οΈ Efficient and reusable C++ code


πŸ›  Installation & Usage

πŸ“₯ Clone the Repository

git clone https://github.com/AmrTamerDev/clsInput_Validation_Library-CPP.git
cd clsInput_Validation_Library-CPP

πŸ“œ License

This project is open-source. Feel free to fork, modify, and use it in your own C++ applications! πŸŽ‰


🀝 Contributions

Contributions are welcome! If you have improvements or additional features to add, submit a Pull Request πŸš€

About

A C++ library for validating user input, including numeric range checks, date validation, and safe string reading. It ensures robust and error-free input handling in console applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages