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
They all will be children of any of two common ancestors,
TSQLRecordfield content validation is handled in the new
TSQLRecord.Validatevirtual method, or via some
TSQLRecordfield content filtering is handled in the new
TSQLRecord.Filtervirtual method, or via some
Some "standard" classes are already defined in the
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
classes) and validation (using one of the
The unique field validation is now in
TSQLRecord. Validate and
SQLite3UIEdit itself (to have a better multi-tier
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; begin for i := 0 to high(FileTabs) do Classes[i] := FileTabs[i].Table; result := TSQLModel.Create(Classes,'synfile'); result.Owner := Owner; result.SetActions(TypeInfo(TFileAction)); result.SetEvents(TypeInfo(TFileEvent)); TSQLFile.AddFilterOrValidate('Name',TSQLFilterLowerCase); TSQLUser.AddFilterOrValidate('Email',TSQLValidateEmail); end;
AddFilterOrValidate method is enough to declare
the validation for the whole framework.
Feedback and comments are welcome in our forum.