#2 Re: mORMot 1 » Server Side Validation » 2015-04-07 14:10:59

ws

sorry, I'll try again.

this link "http://synopse.info/forum/viewtopic.php?id=1500" has a reference to this property.

TSQLServerRest.ServerSideValidate := true;

#3 mORMot 1 » Server Side Validation » 2015-04-07 01:12:35

ws
Replies: 7

The TSQLServerRest class, already had the ServerSideValidate property, if yes, why was excluded?

#4 Re: mORMot 1 » Restfull Validation » 2015-04-02 16:34:14

ws

ok, now I understand. I'll need to use Delphi to my client app, and if I am working with client made with html / css / js, is it possible that my server app return me an error message if there was any violation in my restrictions?

it would be possible when making an insert / update / delete and there was no error return a message for example: {"success": "ok"} on error: {"error": "Message"}

#5 Re: mORMot 1 » Restfull Validation » 2015-04-02 14:56:27

ws

I understand that I have to do to override TRecord.Validate class, as well I did. In fact I intend to do a review of the field "name" persona table, it not accepted short description.

I'm using as a basis the project "30 - MVC Server" -> MVCServer.dpr

The following model code.   What else to do?

 unit RESTModel;

interface

uses
  SynCommons,
  mORMot;

type
  TPersona = class(TSQLRecord) // TSQLRecord has already ID: integer primary key
  private
    fName: RawUTF8;
  public
    function Validate(aRest: TSQLRest; const aFields: TSQLFieldBits=[0..MAX_SQLFIELDS-1];
      aInvalidFieldIndex: PInteger=nil; aValidator: PSynValidate=nil): string; override;
  published
    /// ORM will create a NAME VARCHAR(80) column
    property Name:     RawUTF8 index 80 read fName     write fName;
  protected
  end;

function DataModel: TSQLModel;

const
  SERVER_ROOT = 'root';
  SERVER_PORT = '888';

implementation

function TPersona.Validate(aRest: TSQLRest; const aFields: TSQLFieldBits=[0..MAX_SQLFIELDS-1];
      aInvalidFieldIndex: PInteger=nil; aValidator: PSynValidate=nil): string;
var text :String;
begin
  text := '';
  // pseudo code
  if length(name)<=5 then
    text := '{"error":"should be above 5 characters"}';
  result := UTF8ToString(text);
end;

function DataModel: TSQLModel;
begin
  result := TSQLModel.Create([TPersona],SERVER_ROOT);
  
  TPersona.AddFilterOrValidate('Name',TSynValidateText.Create('{"minlength": 5}'));
end;


end.

#6 Re: mORMot 1 » Restfull Validation » 2015-04-01 17:18:34

ws

returning to the tests.

I used the Validate method of TSQLRecord class, doing override, code below:

   ...

  TPersona = class(TSQLRecord)
  private
    fName: RawUTF8;
    fEndereco: RawUTF8;
  public
    function Validate(aRest: TSQLRest; const aFields: TSQLFieldBits=[0..MAX_SQLFIELDS-1];
      aInvalidFieldIndex: PInteger=nil; aValidator: PSynValidate=nil): string; override;
  published

  ...

function TPersona.Validate(aRest: TSQLRest; const aFields: TSQLFieldBits=[0..MAX_SQLFIELDS-1];
      aInvalidFieldIndex: PInteger=nil; aValidator: PSynValidate=nil): string;
var texto :String;
begin
  texto := '{"error":"only test"}';
  result := UTF8ToString(texto);
end;

at what time the validate method is called, I created a new record and did not return the message. 

how to call the validate function.

#7 Re: mORMot 1 » Restfull Validation » 2015-03-25 01:44:30

ws

I tried this code, also did not work, was recorded in the database with two characters

function DataModel: TSQLModel;
begin
  result := TSQLModel.Create([TPersona],SERVER_ROOT);
  TPersona.AddFilterOrValidate('Name',TSynValidateText.Create('{"minlength": 5, "MaxLength": 10}'));
end;

#8 Re: mORMot 1 » Restfull Validation » 2015-03-25 01:02:37

ws

I found this code :

SQLRecordClasses[iClasses].AddFilterOrValidate(List^[iProps]^.Name,
            TSynValidateText.Create(Format('{"MinLength":0,"MaxLength":%d}', [list^[iProps]^.Index])));

#9 Re: mORMot 1 » Restfull Validation » 2015-03-24 23:02:42

ws

even putting this check is writing to the database, presenting no error.

function DataModel: TSQLModel;
begin
  result := TSQLModel.Create([TPersona],SERVER_ROOT);
  TPersona.AddFilterOrValidate('Name',TSynValidateText.Create(''));
end;

how can I use {"minlength": 5, "MaxLength": 10} in TSynValidateText, which syntax.

#10 mORMot 1 » Restfull Validation » 2015-03-23 14:22:39

ws
Replies: 10

how to validate a field that is empty in app Restfull

#11 mORMot 1 » Insert Multiple » 2015-03-21 20:10:44

ws
Replies: 1

I am passing this parameter : [{"id":8,"name":"aaaa"}, {"id":9,"name":"bbbb"}]

, but is only recorded the first record, how to record all.

URL : http://localhost:888/root/person

POST

CONTENT TYPE : application/json      -     [{"id":8,"name":"Chaves"}, {"id":9,"name":"Super"}]

I'm using httprequester to do my tests

#12 Re: mORMot 1 » Compatible Projects - FPC » 2015-03-21 19:33:58

ws

congratulations to everyone for the great job they did, with little effort can insert, update and delete.

Not found in any language what the mormot offers.

#13 Re: mORMot 1 » Compatible Projects - FPC » 2015-03-20 17:32:44

ws

I will test with Delphi xe5.

#14 Re: mORMot 1 » Compatible Projects - FPC » 2015-03-20 16:49:48

ws

Thanks !

Unfortunately I will have to wait for the FPC RTTI

#15 mORMot 1 » Compatible Projects - FPC » 2015-03-20 14:32:08

ws
Replies: 7

which projects in sample are compatible with fpc and are functional.

especially projects:

26 - RESTful ORM
28 - Simple RESTful ORM Server
30 - Server MVC

#17 Re: mORMot 1 » FPC - Example - 30 - MVC Server » 2015-03-17 18:18:51

ws

with MVCServer.dpr project have these errors:

MVCModel.pas(380,20) Error: Incompatible types: got "Pointer" expected "TPUtf8CharArray"
380,20 ====> fResults[f] := pointer(fFields[f]);


MVCModel.pas(387,36) Error: Incompatible types: got "PUTF8Char" expected "TPUtf8CharArray"
387,36 ====> fResults[r*fFieldCount+f] := P;

MVCModel.pas(541,80) Error: Incompatible type for arg no. 6: Got "<address of function(Pointer;Pointer):LongInt;Register>", expected "<procedure variable type of function(PUTF8Char;PUTF8Char):LongInt;Register>"
541,80 ====> AddSortedRawUTF8(tags,tagsCount,tagTable.GetU(r,meta_id),nil,-1,@StrIComp);


MVCModel.pas(579,77) Error: Incompatible type for arg no. 4: Got "<address of function(Pointer;Pointer):LongInt;Register>", expected "<procedure variable type of function(PUTF8Char;PUTF8Char):LongInt;Register>"
579,77 ====> pointer(tags),high(tags),tagTable.FieldBuffer(meta_id),@StrIComp);

#18 Re: mORMot 1 » FPC - Example - 30 - MVC Server » 2015-03-17 16:38:29

ws

the problem happens in the project "MainDemo" with this message: mORMoti18n.pas (2568.0) Fatal: Unexpected end of file

coincidentally both mORMoti18n.pas and SynDBZeos are commented, right?

sorry my english!

#19 mORMot 1 » FPC - Example - 30 - MVC Server » 2015-03-17 15:06:06

ws
Replies: 6

I'm new to the group.

I used fpc 3.1.1 and 1.5 Lazarus, I downloaded here: https://vdebris.wordpress.com/lazarus-2-7-1-snapshot/
Zeos 7.2

I use windows (32) - compiling example: 30 - MVC Server introduced this error in the compilation:

SynDBZEOS.pas (1170.0) Fatal: Unexpected end of file

Could someone give help to do?

Board footer

Powered by FluxBB