okTurtles / group-income

A decentralized and private (end-to-end encrypted) financial safety net for you and your friends.
https://groupincome.org
GNU Affero General Public License v3.0
329 stars 43 forks source link

Broken validators #2352

Closed taoeffect closed 4 days ago

taoeffect commented 4 days ago

Problem

In 'gi.contracts/group/updateSettings', I mistakenly thought that these custom validation functions in objectMaybeOf worked:

    'gi.contracts/group/updateSettings': {
      // OPTIMIZE: Make this custom validation function
      // reusable accross other future validators
      validate: actionRequireActiveMember((data, { getters, meta, message: { innerSigningContractID } }) => {
        objectMaybeOf({
          groupName: stringMax(GROUP_NAME_MAX_CHAR, 'groupName'),
          groupPicture: x => typeof x === 'string',
          sharedValues: stringMax(GROUP_DESCRIPTION_MAX_CHAR, 'sharedValues'),
          mincomeAmount: x => typeof x === 'number' && x > 0,
          mincomeCurrency: stringMax(GROUP_CURRENCY_MAX_CHAR, 'mincomeCurrency'),
          distributionDate: x => typeof x === 'string',
          allowPublicChannels: x => typeof x === 'boolean'
        })(data)

But they do not.

The problem is that the custom validators do not throw an exception.

Similar problem in 'gi.contracts/group/groupProfileUpdate' too.

EDIT: similarly, there is another big problem that validators from outside of flowTyper.js, like isIsoString and isPeriodStamp are used with objectMaybeOf.

Solution