Swift DDP and MDG Validated Method


#1

Hello all,
I am using Swift DDP to build a native iOS app with Meteor as my back end. I am using MDG Validated Method for my methods with Simple-Schema for validation.
For example:
export const example = new ValidatedMethod({ name: 'examples.example', validate: new SimpleSchema({ name: { type: String }, value: { type: Number }, }).validator(), run({ name, value }) { console.log(name, value); } });

I can’t seem to get valid JSON to pass through to the method. Every time I get the error "Exception while invoking method ‘sensors.insert’ Error: The first argument of validate() or validateOne() must be an object."
Any help?
Thanks!


#2

How are you invoking the method from Swift?


#3

We actually got it to work (I don’t know how to delete / close posts on here).
For anyone who is curious we simply had to call the method like:

let params = [
  "name": 'hi',
   "value": 1
]
Meteor.call("examples.example", params: [params]){ result, error in
  print(result)
  //print(error!)
}

Before we were trying to serialize the JSON data but Swift does it for you!
Great package and as always Meteor is fab.