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

Suggestion: Support Property Constraints #481

Closed
pjeanjean opened this issue Aug 9, 2022 · 2 comments
Closed

Suggestion: Support Property Constraints #481

pjeanjean opened this issue Aug 9, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@pjeanjean
Copy link

Hi,

This issue is a follow-up to a discussion on the Discord server.

Currently, ArcadeDB doesn't have support to define constraints on properties other than their type.
The only property setting currently implemented is default, which works nice but isn't properly documented in the manual from what I can tell.

Now that the project is pretty mature, users would benefit a lot if the constraints defined here were implemented:

// String attrName = settingName.getStringValue();
// Object attrValue = this.settingValue == null ? true : this.settingValue.execute((Identifiable) null, ctx);
// try {
// if (attrName.equalsIgnoreCase("readonly")) {
// internalProp.setReadonly((boolean) attrValue);
// } else if (attrName.equalsIgnoreCase("mandatory")) {
// internalProp.setMandatory((boolean) attrValue);
// } else if (attrName.equalsIgnoreCase("notnull")) {
// internalProp.setNotNull((boolean) attrValue);
// } else if (attrName.equalsIgnoreCase("max")) {
// internalProp.setMax("" + attrValue);
// } else if (attrName.equalsIgnoreCase("min")) {
// internalProp.setMin("" + attrValue);
// } else if (attrName.equalsIgnoreCase("default")) {
// if(this.settingValue==null){
// throw new PCommandExecutionException("");
// }
// internalProp.setDefaultValue("" + attrValue);
// } else if (attrName.equalsIgnoreCase("collate")) {
// internalProp.setCollate("" + attrValue);
// } else if (attrName.equalsIgnoreCase("regexp")) {
// internalProp.setRegexp("" + attrName);
// } else {
// throw new PCommandExecutionException("Invalid attribute definition: '" + attrName + "'");
// }
// } catch (Exception e) {
// throw new PCommandExecutionException("Cannot set attribute on property " + settingName.getStringValue() + " " + attrValue, e);
// }
// return attrValue;

This would also bring the project closer to feature parity with OrientDB.

@lvca lvca self-assigned this Aug 9, 2022
@lvca lvca added the enhancement New feature or request label Aug 9, 2022
@lvca lvca added this to the 22.9.1 milestone Aug 10, 2022
@lvca
Copy link
Contributor

lvca commented Aug 10, 2022

Nice, I was able to reuse >90% of the code + tests from OrientDB. Still finishing the last things and it should be released soon.

@lvca
Copy link
Contributor

lvca commented Aug 10, 2022

The following are going to be supported:

  • mandatory (the property must be present)
  • readonly (the property cannot be changed after the creation of the record)
  • min (minimum value)
  • max (maximum value)
  • regexp (Regular Expression)

lvca added a commit that referenced this issue Aug 10, 2022
…rties constrants

Implemented issue #481.

Now property can have the following constraints:
- mandatory (the property must be present)
- readonly (the property cannot be changed after the creation of the record)
- min (minimum value)
- max (maximum value)
- regexp (Regular Expression)
@lvca lvca closed this as completed Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants