@ukhomeoffice/cop-react-form-renderer 5.65.0 → 5.65.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _elevateNestedComponents = _interopRequireDefault(require("../Component/elevateNestedComponents"));
7
8
  var _validateComponent = _interopRequireDefault(require("./validateComponent"));
8
9
  var _additional = _interopRequireDefault(require("./additional"));
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -35,7 +36,8 @@ var validateContainer = function validateContainer(container, outerData, formDat
35
36
  var errors = [];
36
37
  if (Array.isArray(container.components)) {
37
38
  var containerData = outerData && container.fieldId ? outerData[container.fieldId] : outerData;
38
- container.components.forEach(function (component) {
39
+ var fullContainerComponents = (0, _elevateNestedComponents.default)(container.components, containerData);
40
+ fullContainerComponents.forEach(function (component) {
39
41
  // It is possible that the container being passed in is a
40
42
  // dummy container just for validation. In that scenario we want
41
43
  // to ignore the full_path and just use the component's fieldId.
@@ -72,4 +72,37 @@ describe('utils.Validate.Container', function () {
72
72
  id: ID
73
73
  });
74
74
  });
75
+ it('should return an array containing errors for nested components if the container has them as children', function () {
76
+ var ID = 'container';
77
+ var LABEL = 'field';
78
+ var CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
79
+ CONTAINER.components = [{
80
+ id: 'testRadio',
81
+ fieldId: 'testRadio',
82
+ type: 'radios',
83
+ data: {
84
+ options: [{
85
+ value: 'yes',
86
+ nested: [{
87
+ id: 'nestedText',
88
+ fieldId: 'nestedText',
89
+ type: 'text',
90
+ required: true,
91
+ custom_errors: [{
92
+ type: 'required',
93
+ message: 'Nested text is required'
94
+ }]
95
+ }]
96
+ }]
97
+ }
98
+ }];
99
+ var DATA = _defineProperty({}, ID, {
100
+ testRadio: 'yes'
101
+ });
102
+ expect((0, _validateContainer.default)(CONTAINER, DATA)).toEqual([{
103
+ id: "".concat(ID, ".nestedText"),
104
+ error: 'Nested text is required',
105
+ properties: undefined
106
+ }]);
107
+ });
75
108
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.65.0",
3
+ "version": "5.65.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",