Skip to content

Commit

Permalink
Fix regex validation in Product type for fields that specify USD
Browse files Browse the repository at this point in the history
This applies to pricePerUnit, setupFee and costMonth fields
  • Loading branch information
miguelsorianod committed Aug 4, 2020
1 parent 490504a commit 7d731f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions deploy/crds/capabilities.3scale.net_products_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
type: boolean
costMonth:
description: Cost per Month (USD)
pattern: ^\d+.?\d{2}$
pattern: ^\d+(\.\d{2})?$
type: string
limits:
description: Limits
Expand Down Expand Up @@ -115,7 +115,7 @@ spec:
type: object
pricePerUnit:
description: Price per unit (USD)
pattern: ^\d+.?\d{2}$
pattern: ^\d+(\.\d{2})?$
type: string
to:
description: Range To
Expand All @@ -129,7 +129,7 @@ spec:
type: array
setupFee:
description: Setup fee (USD)
pattern: ^\d+.?\d{2}$
pattern: ^\d+(\.\d{2})?$
type: string
trialPeriod:
description: Trial Period (days)
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/capabilities/v1beta1/product_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type PricingRuleSpec struct {
MetricMethodRef MetricMethodRefSpec `json:"metricMethodRef"`

// Price per unit (USD)
// +kubebuilder:validation:Pattern=`^\d+.?\d{2}$`
// +kubebuilder:validation:Pattern=`^\d+(\.\d{2})?$`
PricePerUnit string `json:"pricePerUnit"`
}

Expand All @@ -116,12 +116,12 @@ type ApplicationPlanSpec struct {
TrialPeriod *int `json:"trialPeriod,omitempty"`

// Setup fee (USD)
// +kubebuilder:validation:Pattern=`^\d+.?\d{2}$`
// +kubebuilder:validation:Pattern=`^\d+(\.\d{2})?$`
// +optional
SetupFee *string `json:"setupFee,omitempty"`

// Cost per Month (USD)
// +kubebuilder:validation:Pattern=`^\d+.?\d{2}$`
// +kubebuilder:validation:Pattern=`^\d+(\.\d{2})?$`
// +optional
CostMonth *string `json:"costMonth,omitempty"`

Expand Down

0 comments on commit 7d731f7

Please sign in to comment.