getWarningAndErrors method

  1. @override
EditorWarningAndErrorsEntity getWarningAndErrors(
  1. ID nodeID,
  2. BuildContext context
)
override

Implementation

@override
EditorWarningAndErrorsEntity getWarningAndErrors(
  ID nodeID,
  BuildContext context,
) {
  if (variableID == null) {
    return EditorWarningAndErrorsEntity(
      warnings: const [],
      errors: [
        MissingVariableWarningEntity(
          nodeID: nodeID,
          message: 'Variable ID is null',
        ),
      ],
    );
  }
  if (variableID!.isEmpty) {
    return EditorWarningAndErrorsEntity(
      warnings: const [],
      errors: [
        MissingVariableWarningEntity(
          nodeID: nodeID,
          message: 'Variable ID is empty',
        ),
      ],
    );
  } else {
    try {
      context.getVariableById(
          variableID: variableID!, cubitID: cubitID!, stateID: stateID!);
    } catch (e) {
      return EditorWarningAndErrorsEntity(
        warnings: const [],
        errors: [
          MissingVariableWarningEntity(
            nodeID: nodeID,
            message: 'Variable not found',
          ),
        ],
      );
    }
    if (type != VariableTypes.json) {
      return EditorWarningAndErrorsEntity(
        warnings: const [],
        errors: [
          EditorErrorEntity(
            nodeID: nodeID,
            message: 'Variable type is not Json',
          ),
        ],
      );
    }
  }

  if (jsonPath.isEmpty) {
    return EditorWarningAndErrorsEntity(
      warnings: const [],
      errors: [
        EditorErrorEntity(
          nodeID: nodeID,
          message: 'Json path is empty',
        ),
      ],
    );
  }
  return const EditorWarningAndErrorsEntity();
}