-
Notifications
You must be signed in to change notification settings - Fork 827
Open
Labels
flag: needs discussionIssues which needs discussion before implementation.Issues which needs discussion before implementation.type: featureIssues related to new features.Issues related to new features.
Description
Description
Unlike strings, array fields often contain a fixed number of elements (i.e. consider the case where the coordinates are received as an array of size 2), and I usually have to validate this manually by checking the minimum size and the maximum size simultaneously. Although this issue is easy to overcome, a more direct approach would improve readability and produce cleaner code.
Proposed solution
I propose creating the @ArraySize
decorator that validates the array's size against the provided argument
// proposed implementation
class Example {
@ArraySize(2) // accept only arrays with 2 entries
coordinates: number[];
}
// same feature with current tools
class Example {
@ArrayMinSize(2)
@ArrayMaxSize(2)
coordinates: number[]
}
Metadata
Metadata
Assignees
Labels
flag: needs discussionIssues which needs discussion before implementation.Issues which needs discussion before implementation.type: featureIssues related to new features.Issues related to new features.