ValidationResponse.fromSubResponses constructor

ValidationResponse.fromSubResponses({
  1. required String? validationError,
  2. required String? stateError,
  3. required List<Response<EventValidate, dynamic>> subResponses,
})

Implementation

factory ValidationResponse.fromSubResponses(
    {required String? validationError,
    required String? stateError,
    required List<Response<EventValidate, dynamic>> subResponses}) {
  return ValidationResponse(
    dataValidationError: validationError,
    stateError: stateError,
    childrenCanSave: subResponses.isEmpty ||
        subResponses.every(
            (element) => (element.result is! ValidationResponse || (element.result as ValidationResponse).canSave)),
    childrenHaveErrors: subResponses.isNotEmpty &&
        subResponses.any(
            (element) => (element.result is ValidationResponse && (element.result as ValidationResponse).hasError)),
  );
}