Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmou committed Apr 8, 2020
1 parent 18cc793 commit bac147b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/schema3.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/wot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/schema3.iced
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class String extends Node

_check : ({path, obj}) ->
if typeof(obj) isnt 'string' or obj.length is 0 then return mkerr path, "value must be a string"
if @_args? and @_args.maxLength?
if obj.length > @_args.maxLength then return mkerr path, "value length needs to be < #{@_args.maxLength}"
if (max_length = @_args?.max_length)?
if obj.length > max_length then return mkerr path, "value length needs to be < #{max_length}"
return null

class StringEnum extends Node
Expand Down
4 changes: 2 additions & 2 deletions src/wot.iced
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ exports.Vouch = class Vouch extends Base
confidence : schema.dict({
username_verified_via : schema.string_enum(["in_person", "proofs", "video", "audio", "other_chat", "familiar", "other"]).optional()
proofs: schema.array(proof_schema).optional()
other : schema.string({maxLength: 90}).optional()
other : schema.string({max_length: 90}).optional()
})
failing_proofs : schema.array(proof_schema).optional()
vouch_text : schema.string({maxLength: 700})
vouch_text : schema.string({max_length: 700})
})
err = schm.check(obj)
cb err
Expand Down
3 changes: 2 additions & 1 deletion test/files/wot.iced
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ exports.wot_vouch_bad = (T,cb) ->
verifier = alloc out.inner.obj.body.type, me
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
await verifier.verify_v2 varg, defer err
T.assert err?, "expecting error"
T.assert err?, "got an error back"
T.assert (err.message.indexOf(".confidence.other") >= 0), "found right error message"

cb null

0 comments on commit bac147b

Please sign in to comment.