Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated model for id:Guid is incorrect #31

Open
avallee opened this issue Jun 17, 2021 · 1 comment
Open

Generated model for id:Guid is incorrect #31

avallee opened this issue Jun 17, 2021 · 1 comment

Comments

@avallee
Copy link

avallee commented Jun 17, 2021

Ran dotnet saturn gen.json test test id:guid other:string and got this output which does not build (isNull u.id).

namespace test

[<CLIMutable>]
type test = {
  id: System.Guid
  other: string
}

module Validation =
  let validate v =
    let validators = [
      fun u -> if isNull u.id then Some ("id", "Id shouldn't be empty") else None
    ]

    validators
    |> List.fold (fun acc e ->
      match e v with
      | Some (k,v) -> Map.add k v acc
      | None -> acc
    ) Map.empty

I would think that for a Guid, it'd be something like a Guid.Empty = u.id.

@kierepka
Copy link

kierepka commented Oct 3, 2021

I made this same change:

let validators = [
      fun u -> if (u.id=System.Guid.Empty) then Some ("id", "Id shouldn't be empty") else None
    ]

But I got this error: ```

ERROR #500
Error parsing column 0 (id=6511E9C7-0046-4EBC-B94E-B87591BDB5DC - String)
BioMindsXR_SRV
at [email protected](FSharpResult`2 _arg1) in D:\GitHub\BioMinds_SRV\src\BioMindsXR_SRV\Users\UsersController.fs:line 18 at

Inner error:`
Invalid cast from 'System.String' to 'System.Guid'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants