Skip to content

Conversation

@mihailkitrozoskicodechem
Copy link
Collaborator

@mihailkitrozoskicodechem mihailkitrozoskicodechem commented Jan 16, 2026

Implements the ability for users to specify minimum and maximum values on number and text properties.

Closes #222

}
}

static validMinField(control: AbstractControl): ValidationErrors | null {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've noticed that the validators do not handle cases where characters other than numbers are provided. This input passes frontend validation without errors; however, it neither causes a backend failure nor results in the attribute being added to the model. While this is not expected to cause issues since the input is invalid, it would be preferable to validate this on the frontend before sending the request to the backend.

image

@if (fieldForm.hasError('minGreaterThanMax') &&
(fieldForm.get('minLength')?.touched || fieldForm.get('maxLength')?.touched)) {
<mat-error class="cross-field-error">
Min length cannot be greater than max length
Copy link
Collaborator

Choose a reason for hiding this comment

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

The error messages vary across the dialogs. It would be nice to follow a consistent design.
image
Screenshot 2026-01-16 at 13 36 24
image

var min = string.IsNullOrEmpty(minLength) ? "0" : minLength;
var max = string.IsNullOrEmpty(maxLength) ? DefaultMaxLength.ToString() : maxLength;

var attribute = SyntaxFactory.Attribute(SyntaxFactory.ParseName("Length"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we always create them with [Length]? If I provide only maxLength I would expect to have only the [MaxLength] attribute and same goes for [MinLength].

min="1"
max="1000"
step="1"
formControlName="minLength"
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a missing placeholder for minLength.

...(this.selectedFieldTypeId === this.fieldTypeEnum.String && this.fieldForm.value.minLength && { minLength: this.fieldForm.value.minLength }),
...(this.selectedFieldTypeId === this.fieldTypeEnum.String && this.fieldForm.value.maxLength && { maxLength: this.fieldForm.value.maxLength }),
...((this.selectedFieldTypeId === this.fieldTypeEnum.Number || this.selectedFieldTypeId === this.fieldTypeEnum.Float || this.selectedFieldTypeId === this.fieldTypeEnum.Double) && this.fieldForm.value.minValue !== null && this.fieldForm.value.minValue !== undefined && this.fieldForm.value.minValue !== '' && { minValue: this.fieldForm.value.minValue }),
...((this.selectedFieldTypeId === this.fieldTypeEnum.Number || this.selectedFieldTypeId === this.fieldTypeEnum.Float || this.selectedFieldTypeId === this.fieldTypeEnum.Double) && this.fieldForm.value.maxValue !== null && this.fieldForm.value.maxValue !== undefined && this.fieldForm.value.maxValue !== '' && { maxValue: this.fieldForm.value.maxValue })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you refactor this by extracting parts into separate methods and introducing boolean variables or similar constructs? The current implementation is becoming increasingly complex, making it difficult to follow the logic.

(this.isTextType() && formValue.regex !== (this.data.regex || '')) ||
(this.isDateType() && formValue.noPastDates !== (this.data.noPastDates || false))
(this.isDateType() && formValue.noPastDates !== (this.data.noPastDates || false)) ||
(this.isTextType() && (formValue.minLength !== (this.data.minLength ?? null) || formValue.maxLength !== (this.data.maxLength ?? null))) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar note to the previous one, try to take out these in separate variables.

hasIndex?: boolean;
regex?: string;
noPastDates?: boolean;
minLength?: number | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need explicit nullability here? The optional property already covers undefined.

hasIndex: boolean;
regex?: string;
noPastDates?: boolean;
minLength?: number | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as before, the optional property covers undefined. Make sure you have consistent code everywhere.


public int? MaxLength { get; set; }

public double? MinValue { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

The MinValue and MaxValue here are of type double. While in Property.cs they are strings. Was this intentional?

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.

Min, max values

3 participants