opencrvs / opencrvs-core

A global solution to civil registration
https://www.opencrvs.org
Other
85 stars 67 forks source link

Custom country config validators are not loaded on form first load preventing offline support #7478

Open tahmidrahman-dsi opened 1 month ago

tahmidrahman-dsi commented 1 month ago

custom country config validators are not loaded on form first load, produces this error

Error: Cannot find a validator with a name validIDNumberCustom.
    This is a configuration error in your country specific resource package's form field definitions.
    at configurationError (deserializer.ts:111:10)
    at fieldValidationDescriptorToValidationFunction (deserializer.ts:226:11)
    at deserializer.ts:301:9
    at Array.map (<anonymous>)
    at deserializeFormField (deserializer.ts:300:23)
    at deserializer.ts:393:14
    at Array.map (<anonymous>)
    at deserializer.ts:392:26
    at Array.map (<anonymous>)
    at deserializeFormSection (deserializer.ts:390:33)

Mainly because when forms are loaded from indexedDB before fetching countryconfig validators, redux action OFFLINE/FORMS_LOADED is called with validators parameter having built in ones. https://github.com/opencrvs/opencrvs-core/blob/release-v1.5.0/packages/client/src/forms/register/reducer.ts#L52 Potential effect of this might be forms having custom countryconfig validators may not work offline

Even when offline data succeeds and the app is offline, it might not even try fetching from cache https://github.com/opencrvs/opencrvs-core/blob/release-v1.5.0/packages/client/src/offline/reducer.ts#L377

rikukissa commented 3 weeks ago

@SyedaAfrida @eduffus define a custom validator in Farajaland please

SyedaAfrida commented 3 weeks ago

Once #7510 is ready this bug can be tested in core