Because the "change PIN" functionality has been split into two stages, the changingPin state hook will now take a callback that just accepts a new pin -- ie it is identical to the SetNewPinCb type. So just delete ChangePinCb and use SetNewPinCb instead.
[x] add another field to the context (validationErrors). This needs to be an array because there could be multiple validation errors. Going forwards, this could and probably should be merged with the existing errors, but for now, it is easier to add a second type of error as it doesn't conflict with existing logic.
[x] add another event type for sending validation errors. unnecessary, hooks handle this on their own now
[x] add a second argument to some of the hooks that will accept a map of [RegExp, VALIDATION_ERROR_MESSAGE]. This allows for a set of validators to be defined that can be applied statically to the input value. This should default to an empty array.
[x] add another error message type in addition to the core ones, use string template type VALIDATION_ERROR_{string}. unnecessary, hooks handle this on their own now
[x] in the relevant hooks, before a network request is made, check for any validators. Cycle through them, and push any that fail into a validation errors array. Then send that back.
Resolves #76 Resolves #77 Resolves #79 Resolves #80 Resolves #81 Resolves #82
Because the "change PIN" functionality has been split into two stages, the changingPin state hook will now take a callback that just accepts a new pin -- ie it is identical to the SetNewPinCb type. So just delete ChangePinCb and use SetNewPinCb instead.
[x] add another field to the context (
validationErrors
). This needs to be an array because there could be multiple validation errors. Going forwards, this could and probably should be merged with the existing errors, but for now, it is easier to add a second type of error as it doesn't conflict with existing logic.[x]
add another event type for sending validation errors.unnecessary, hooks handle this on their own now[x] add a second argument to some of the hooks that will accept a map of
[RegExp, VALIDATION_ERROR_MESSAGE]
. This allows for a set of validators to be defined that can be applied statically to the input value. This should default to an empty array.[x]
add another error message type in addition to the core ones, use string template typeunnecessary, hooks handle this on their own nowVALIDATION_ERROR_{string}
.[x] in the relevant hooks, before a network request is made, check for any validators. Cycle through them, and push any that fail into a validation errors array. Then send that back.