https://github.com/mikemajesty/coolvalidator
Library - TextBox and object validator | C# Windows Form.
https://github.com/mikemajesty/coolvalidator
textbox validate validatemanytextbox validatetexbox
Last synced: 10 months ago
JSON representation
Library - TextBox and object validator | C# Windows Form.
- Host: GitHub
- URL: https://github.com/mikemajesty/coolvalidator
- Owner: mikemajesty
- License: mit
- Created: 2016-10-21T16:01:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-06T15:00:26.000Z (about 8 years ago)
- Last Synced: 2025-04-09T12:38:55.216Z (11 months ago)
- Topics: textbox, validate, validatemanytextbox, validatetexbox
- Language: C#
- Homepage:
- Size: 81.1 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CoolValidator - Validate TexBox now is easy
## How to install
```
Install-Package coolvalidator
```
## How to use
#### Namespace
```
using CoolValidator;
```
## Validate TextBox
___
#### Default validator
```C#
private void btnSave(object sender, EventArgs e)
{
this.ValidateTextBox(ValidateType.IS_EMPTY, PostValidate);
}
private void PostValidate()
{
MessageBox.Show("Field is Required");
}
```
-
ValidateType.IS_EMPTY - Verify if the TextBox is empty -
PosValidateAction - The method that will run after validation
___
#### Custom validator
```C#
private void btnSave(object sender, EventArgs e)
{
this.ValidateTextBox(ValidateType.NONE, PostValidate, c =>
string.IsNullOrEmpty(c.Text) && c.Tag.Equals("Required"));
}
private void PostValidate()
{
MessageBox.Show("Field is Required");
}
```
-
ValidateType.NONE - Indicate that none validate it will be executed -
PosValidateAction - The method that will run after validation -
c => string.IsNullOrEmpty(c.Text) && c.Tag.Equals("Required") - Condition to validate a TextBox, you can put anything.
To validate the example above it's necessary that TextBox be empty and its Tag property be "Required"
[](https://postimg.org/image/s82tjwmi3/)
#### Custom and default validator
```C#
private void btnSave(object sender, EventArgs e)
{
this.ValidateTextBox(ValidateType.IS_EMPTY, PostValidate, c =>
c.Tag.Equals("Required"));
}
private void PostValidate()
{
MessageBox.Show("Field is Required");
}
```
-
ValidateType.IS_EMPTY - Varify if the TextBox is empty -
PosValidateAction - The method that will run after validation -
c => c.Tag.Equals("Required") - Condition to validate a TextBox, you can put anything.
___
## Validate Entity
___
#### Firstly you must create a class with Annotation, example
[](https://postimg.org/image/ceigqprsz/)
To validate your entity use
[](https://postimg.org/image/t2f0qbsw3/)
In the example above we took in the first error a list of possible errors, The error list is composed of
[](https://postimg.org/image/yb4zr34zn/)
Then we showed the error in a MessageBox
[](https://postimg.org/image/k8o4985xf/)
You can do whatever you want with these error messages, make yourself comfortable
### License
It is available under the MIT license.
[License](https://opensource.org/licenses/mit-license.php)