#1 2024-12-14 09:42:20

mrbar2000
Member
From: Brazil
Registered: 2016-10-26
Posts: 100

TSynValidate To DTO record

There are in mormot some class to make validate in DTOs records?
I need make some simple validates on service before call my repositories passing DTOs. what u think about this?
Other question. Where I found documentation or sample to translate Tsynvalidate messages?

Offline

#2 2024-12-16 17:41:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,742
Website

Re: TSynValidate To DTO record

Please try
https://github.com/synopse/mORMot2/commit/f5d80f61

Now you can use TRttiFilter to filter and/or validate any class or record.
See the regression tests as reference:
https://github.com/synopse/mORMot2/commit/08259ec2

Offline

#3 2024-12-20 11:38:31

mrbar2000
Member
From: Brazil
Registered: 2016-10-26
Posts: 100

Re: TSynValidate To DTO record

Where I found documentation or sample to translate Tsynvalidate messages?

Offline

#4 2024-12-20 11:56:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,742
Website

Re: TSynValidate To DTO record

As I wrote, see the regression tests as reference.

Offline

#5 2024-12-20 16:44:21

mrbar2000
Member
From: Brazil
Registered: 2016-10-26
Posts: 100

Re: TSynValidate To DTO record

I look on regression tests, on blog in on source.

I need change the default error message of TSynValidate. for sample:

function TSynValidateEmail.Process(aFieldIndex: integer; const value: RawUtf8;
  var ErrorMsg: string): boolean;
...
  ErrorMsg := Format(sInvalidEmailAddress, [Utf8ToString(value)]);  <<<<<<< i need change this message for my language
  result := false;
end;

I dont see no parameter to change this.

Offline

#6 2024-12-20 17:06:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,742
Website

Re: TSynValidate To DTO record

It is a resource string, so you can use the regular Delphi or FPC way to change the language constants for the executable.

Offline

#7 2024-12-23 12:07:23

mrbar2000
Member
From: Brazil
Registered: 2016-10-26
Posts: 100

Re: TSynValidate To DTO record

How I can do this, I see a some time ago that we can use UpdateResource of windows to change resources, but i dunno if will be multiplatarform.
Mormot have something to make this multiplataform way? where i can find instrutions about it?

Could TSynValidates classes have something method that we could override to change this messages?

Offline

Board footer

Powered by FluxBB