/C4D-Validate-Components

Utility for automatic validation of Delphi forms

Primary LanguagePascal

C4D Validate Components

Code4Delphi

Utility for automatic validation of Delphi forms. Excellent to be used for both new projects and legacy products. Facilitating form field validations and reducing code complexity. It can be used for both DBWare and non-DBWare components.

📞 Contacts

     

⚙️ Installation

  • 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

🚀 Quickstart

  • 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);

Custom Attributes available:

  • 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')]

⌨️ Demo

  • 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}

💬 Contributions / Ideas / Bug Fixes

To submit a pull request, follow these steps:

  1. Fork the project
  2. Create a new branch (git checkout -b minha-nova-funcionalidade)
  3. Make your changes
  4. Make the commit (git commit -am 'Functionality or adjustment message')
  5. Push the branch (git push origin Message about functionality or adjustment)
  6. Open a pull request