How to use the italia-ts-commons/lib/responses.ResponseErrorFromValidationErrors function in italia-ts-commons

To help you get started, we’ve selected a few italia-ts-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teamdigitale / io-functions / lib / controllers / adm / services.ts View on Github external
return async (_, __, ___, serviceModelPayload) => {
    const errorOrService = servicePayloadToService(serviceModelPayload);
    if (isLeft(errorOrService)) {
      return ResponseErrorFromValidationErrors(Service)(errorOrService.value);
    }
    const service = errorOrService.value;
    const errorOrCreatedService = await serviceModel.create(
      service,
      service.serviceId
    );
    return errorOrCreatedService.fold<
      IResponseErrorQuery | IResponseSuccessJson
    >(
      error => ResponseErrorQuery("CreateServiceHandler error", error),
      createdService =>
        ResponseSuccessJson(retrievedServiceToPublic(createdService))
    );
  };
}
github teamdigitale / io-functions / lib / utils / middlewares / required_param.ts View on Github external
new Promise(resolve => {
      const validation = type.decode(request.params[name]);
      const result = validation.mapLeft(
        ResponseErrorFromValidationErrors(type)
      );
      resolve(result);
    });
}
github teamdigitale / io-functions / lib / controllers / adm / services.ts View on Github external
new Promise(resolve => {
    const validation = ApiService.decode(request.body);
    const result = validation.mapLeft(
      ResponseErrorFromValidationErrors(ApiService)
    );
    resolve(result);
  });
github teamdigitale / io-functions / lib / controllers / messages.ts View on Github external
new Promise(resolve => {
    return resolve(
      ApiNewMessageWithDefaults.decode(request.body).mapLeft(
        ResponseErrorFromValidationErrors(ApiNewMessageWithDefaults)
      )
    );
  });
github teamdigitale / io-functions / lib / controllers / profiles.ts View on Github external
new Promise(resolve => {
    const validation = ExtendedProfile.decode(request.body);
    const result = validation.mapLeft(
      ResponseErrorFromValidationErrors(ExtendedProfile)
    );
    resolve(result);
  });