- Installation using the Boss:
boss install github.com/Code4Delphi/C4D-Validate-Components
- Manual installation: Open your Delphi and add the following folder to your project, under Project > Options > Resource Compiler > Directories and Conditionals > Include file search path
..\C4D-Validate-Components\Src
- Add uses to your system:
uses
C4D.Validate.Components;
- Insert the Custom Attributes on the component declaration you want to validate:
[FieldDisplay('Name')]
[NotEmpty]
[Length(5, 15)]
edtName: TEdit;
- Make the call for form validation:
TC4DValidateComponents.Validate(TClasseDoForm, Self);
- Name to be displayed if there are errors:
[FieldDisplay('Name to be displayed')]
- Validates so that the field is not empty:
[NotEmpty]
- Enter a minimum and/or maximum number of characters for the field:
[Length(5, 15)]
- Enter the minimum and/or maximum value that must be entered in the field:
[MinMaxValue(5, 10)]
- Enter the minimum and/or maximum date that must be entered in the field
[MinMaxDate('01/12/2023', '10/12/2023')]
- Next to the project sources, you will find a test project, in the folder:
C4D-Validate-Components\Samples\Demo01
Tip
Starting with Delphi version 10.3, if you use a custom attribute that is not known to the compiler (because you typed it incorrectly or a unit is missing in the uses statement), you will receive a Warning:
Warning: W1074 Unknown custom attribute
It is recommended to transform this Warning into an error, so that correction is mandatory, to do so enter:
{$WARN UNKNOWN_CUSTOM_ATTRIBUTE ERROR}
To submit a pull request, follow these steps:
- Fork the project
- Create a new branch (
git checkout -b minha-nova-funcionalidade
) - Make your changes
- Make the commit (
git commit -am 'Functionality or adjustment message'
) - Push the branch (
git push origin Message about functionality or adjustment
) - Open a pull request