-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Feature Description
The BillingPlanDto currently does not support a yearly billing plan properly. The frequency field is a simple string without validation for allowed values, and amount is incorrectly validated as a string instead of a number.
Steps to Reproduce
Attempt to create a billing plan with frequency: 'yearly'.
The request is accepted, but there's no validation ensuring only "monthly" or "yearly" are allowed.
The amount field expects a string instead of a number, which could cause unintended behavior in the system.
Expected Behavior
The frequency field should only accept "monthly" or "yearly" to prevent invalid values.
The amount field should be validated as a number instead of a string.
Current Behavior
The frequency field accepts any string value, leading to potential incorrect configurations.
The amount field is treated as a string, which might cause issues when performing calculations.
The frequency field only supports monthly as a value.
Attempting to use yearly results in validation errors.
Screenshots/Logs
Feature not bug
Environment
OS: Windows/macOS/Linux
Browser/Device: Postman, Chrome, Firefox
Version: Current version of the application.
Possible Solution
Use @isin(['monthly', 'yearly']) for the frequency field to restrict allowed values.
Change @IsNumberString() to @IsNumber() for the amount field to ensure proper type validation.
Additional Context
This issue affects the ability to create and manage billing plans effectively.
Proper validation would improve system stability and prevent misconfigurations.
This feature will provide more flexibility for users and align with common billing practices.
Expected Json Response for both Monthly and Yearly
[
{
"name": "Free",
"description": "Free",
"frequency": "monthly",
"amount": 0,
"is_active": true
},
{
"name": "Premium",
"description": "Premium yearly plan",
"frequency": "yearly",
"amount": 100,
"is_active": true
}
]