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
Replace x => typeof x === 'string' with the string validation function, and do the same for x => typeof x === 'boolean' (except use boolean function validator).
Then for mincomeAmount, use the new numberRange validator
In 'gi.contracts/group/groupProfileUpdate': incomeDetailsType and incomeAmount have a similar problem
Create a validatorFrom function inside of flowTyper.js that takes a function that returns a boolean and throws a validatorError if that function returns false, and then wrap functions like isPeriodStamp with it (when they're called as part of a validation with objectMaybeOf)
Problem
In
'gi.contracts/group/updateSettings'
, I mistakenly thought that these custom validation functions inobjectMaybeOf
worked: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
, likeisIsoString
andisPeriodStamp
are used withobjectMaybeOf
.Solution
x => typeof x === 'string'
with thestring
validation function, and do the same forx => typeof x === 'boolean'
(except useboolean
function validator).mincomeAmount
, use the newnumberRange
validator'gi.contracts/group/groupProfileUpdate'
:incomeDetailsType
andincomeAmount
have a similar problemvalidatorFrom
function inside offlowTyper.js
that takes a function that returns a boolean and throws avalidatorError
if that function returns false, and then wrap functions likeisPeriodStamp
with it (when they're called as part of a validation withobjectMaybeOf
)