getSectionValidation(): TSectionValidation¶
The getSectionValidation
method allows to validate a section containing additional fields and check for potential errors.
Returned value¶
A returned value has a type of TSectionValidation representing an object that tells whether a section was successfully validated or not.
Example¶
In this example we make a basketAdditionalFieldsApi
call to validate the basket section with additional fields.
useStorefront(async (storefront) => {
let basketAdditionalFieldsApi = storefront.getApiSync('basketAdditionalFieldsApi');
if (!basketAdditionalFieldsApi) {
const featureSystemApi = this.getApiSync('FeatureSystemApi');
await featureSystemApi.registerDynamic('basket');
basketAdditionalFieldsApi = storefront.getApiSync('basketAdditionalFieldsApi');
}
const validation = basketAdditionalFieldsApi.getSectionValidation();
});