Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arrayofobjects feature #240

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RayenRomdhane
Copy link

No description provided.

@@ -20,6 +20,9 @@ class ComponentAttributeDefinition {
* @param {boolean} [props.required] - Attribute is required.
* @param {ComponentAttributeDefinition[]} [props.definedAttributes] - Defined attributes for
* this type.
* @param {ComponentAttributeDefinition[]} [props.itemDefinition] - Definition of the structure
* for individual array elements.
* @param {string} [props.itemType] - Type of individual array elements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing explanation on, type we can set on and if defined type is Object an itemDefinition must be provided

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


// eslint-disable-next-line valid-typeof
return this.value.some((item) => typeof item.value !== itemType);
}
}

// eslint-disable-next-line valid-typeof
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remote this line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (this.definition.type === 'Link') {
return !Array.isArray(this.value) || this.value.some((link) => typeof link !== 'string');
}
let typeofvalue = typeof this.value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you need esilnt disable here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no eslint error so I didnt use it.

};
expect(componentAttribute.hasError()).toBeFalsy();

// componentAttribute.definition.rules.values = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -340,6 +347,39 @@ describe('Test class: ComponentAttribute', () => {

componentAttribute.definition.rules.values = null;
});
it('Check type array of object', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to Check if item in array is valid
And add test to check hasError return false when itemtype are not valid

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -307,7 +307,10 @@ describe('Test class: ComponentAttribute', () => {
it('Check if respect all conditions', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put test with according class (in commit)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
## [Unreleased]

### Added
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing guides migration update, to explain that now with have to set itemtype on Array type with some examples. Please read other migration guide to know how to write it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

changelog.md Outdated
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
## [Unreleased]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing break line before

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

changelog.md Outdated

### Changed

- Change `__typeOfValueValidation` in `ComponentAttribute`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation what chane is

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants