gcanti / tcomb-validation

Validation library based on type combinators
MIT License
400 stars 23 forks source link

How to modify struct value #67

Open iyezhou opened 7 years ago

iyezhou commented 7 years ago

Source:

var values = new validate.User.check(req.body);
let sha256 = crypto.createHash("sha256")
let newPwd = sha256.update(values.password).digest("hex")
console.log(values)
console.log(values.password)
console.log(newPwd)
values.password = newPwd
console.log(values.password)

Console print:

Struct {
  username: 'test',
  password: '123456',
  realname: '测试一下',
  age: '25',
  role_id: '1',
  active: '0' }
123456
8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92
123456

I wnat to crypt 'password' field, But Failed