In order to make this easy, a dedicated set of classes are available in the SynCommons.pas unit, and allow to define both filtering and navigation.

They all will be children of any of two common ancestors, named TSynValidate and TSynFilter classes:

  • TSQLRecord field content validation is handled in the new TSQLRecord.Validate virtual method, or via some TSQLValidate classes;
  • TSQLRecord field content filtering is handled in the new TSQLRecord.Filter virtual method, or via some TSQLFilter classes.

Some "standard" classes are already defined in the SynCommons and SQLite3Commons unit, to be used for most common usage:

You have powerful validation classes for IP Address, Email (with TLD+domain name), simple regex pattern, textual validation, strong password validation...

Note that some database-related filtering are existing, like TSynValidateUniqueField which derivates from TSynValidateRest. Thanks to this kind of data-driven classes, you can filter or validate data using all methods of the ORM, in pure Delphi code, with no SQL code to write by hand.

Of course, the SQLite3UIEdit unit now handles TSQLRecord automated filtering (using TSQLFilter classes) and validation (using one of the TSQLValidate classes).

The unique field validation is now in TSQLRecord. Validate and not in SQLite3UIEdit itself (to have a better multi-tier architecture).

To initialize it, you can add some filters/validators to your TSQLModel creation function:

function CreateFileModel(Owner: TSQLRest): TSQLModel;
var Classes: array[0..high(FileTabs)] of TSQLRecordClass;
    i: integer;
  for i := 0 to high(FileTabs) do
    Classes[i] := FileTabs[i].Table;
  result := TSQLModel.Create(Classes,'synfile');
  result.Owner := Owner;

Calling AddFilterOrValidate method is enough to declare the validation for the whole framework.

Feedback and comments are welcome in our forum.