Validator on autoform method-update

Open
#18 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, mongodb
Domain
api, backend, databases

Research direction

Start by reproducing the autoform method-update call with Areas.methods.update and Schemas.Areas.validator(), then inspect how the validation object is passed to ValidatedMethod. Compare the generated modifier with the validation error and verify the expected behavior using the existing issue example.

Written by the indexing model from the issue text.

Description

Hi, i'm using autoform to generate an update form

    {{#with area}}
                {{#autoForm 
                    collection="Areas" 
                    id="updateAreasForm" 
                    type="method-update" 
                    meteormethod="Areas.methods.update"
                    doc=this 
                    class="form-horizontal"
                    }}
                    {{> afQuickField name='nome' label-class="col-sm-3" input-col-class="col-sm-9"}}
                    {{> afQuickField name='tipo' label-class="col-sm-3" input-col-class="col-sm-9"}}
                    {{#unless afFieldValueIs name='tipo' value=1}}
                        {{> afQuickField name='paiId' label-class="col-sm-3" input-col-class="col-sm-9"}}
                    {{/unless}}
                    {{> afQuickField name='ativo' label-class="col-sm-3" input-col-class="col-sm-9"}}
                    {{> submit texto="Editar"}}
                {{/autoForm}}
            {{/with}}

Here's the definition of the method:

Areas.methods.update = new ValidatedMethod({
  name: 'Areas.methods.update',
  validate: Schemas.Areas.validator(),
  run(modifier, _id) {
    console.log(modifier, _id);
    return Areas.update({_id: _id}, modifier);
  }
});

I'm getting this error:

Exception while simulating the effect of invoking 'Areas.methods.update' Error: When the validation object contains mongo operators, you must set the modifier option to true(…) Error: When the validation object contains mongo operators, you must set the modifier option to true
    at doValidation1 (http://localhost:3000/packages/aldeed_simple-schema.js?3d6ebc811c555e8ab1ad73b249a995dc641334ed:2278:11)
    at doValidation (http://localhost:3000/packages/aldeed_simple-schema.js?3d6ebc811c555e8ab1ad73b249a995dc641334ed:2910:10)
    at SimpleSchemaValidationContext.simpleSchemaValidationContextValidate [as validate] (http://localhost:3000/packages/aldeed_simple-schema.js?3d6ebc811c555e8ab1ad73b249a995dc641334ed:2945:21)
    at SimpleSchema.validate (http://localhost:3000/packages/aldeed_simple-schema.js?3d6ebc811c555e8ab1ad73b249a995dc641334ed:2132:35)
    at null.<anonymous> (http://localhost:3000/packages/aldeed_simple-schema.js?3d6ebc811c555e8ab1ad73b249a995dc641334ed:2154:10)
    at ValidatedMethod._execute (http://localhost:3000/packages/mdg_validated-method.js?a862c6e60ea48391f9f16ddbf7d1748fa9231a3b:118:64)
    at ValidatedMethod.connection.methods._connection$methods.(anonymous function) (http://localhost:3000/packages/mdg_validated-method.js?a862c6e60ea48391f9f16ddbf7d1748fa9231a3b:71:21)
    at http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3911:25
    at _.extend.withValue (http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:971:17)
    at _.extend.apply (http://localhost:3000/packages/ddp-client.js?250b63e6c919c5383a0511ee4efbf42bb70a650f:3902:54)

Do you guys have any idea about what is happening? Thanks

Dominant language
JavaScript
Stars
193
Forks
29
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from meteor/validated-method

All issues in meteor/validated-method

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.