mirror of https://github.com/vernonkeenan/lib
189 lines
4.5 KiB
Go
189 lines
4.5 KiB
Go
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
// (c) 2012-2020 by Taxnexus, Inc.
|
|
// All rights reserved worldwide.
|
|
// Proprietary product; unlicensed use is not allowed
|
|
|
|
package members_models
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/strfmt"
|
|
"github.com/go-openapi/swag/jsonutils"
|
|
"github.com/go-openapi/swag/typeutils"
|
|
"github.com/go-openapi/validate"
|
|
)
|
|
|
|
// DescriptiveLimit descriptive limit
|
|
//
|
|
// swagger:model DescriptiveLimit
|
|
type DescriptiveLimit struct {
|
|
|
|
// Always false in this wave; usage accounting is deferred.
|
|
Enforced *bool `json:"enforced,omitempty"`
|
|
|
|
// period
|
|
// Required: true
|
|
// Enum: ["none","day","month","billing_period","lifetime"]
|
|
Period *string `json:"period"`
|
|
|
|
// Exact decimal string matching SQL DECIMAL(20,6).
|
|
// Max Length: 21
|
|
// Min Length: 1
|
|
// Pattern: ^(0|[1-9][0-9]{0,13})(\.[0-9]{1,6})?$
|
|
Quantity *string `json:"quantity,omitempty"`
|
|
|
|
// unit
|
|
// Max Length: 40
|
|
Unit *string `json:"unit,omitempty"`
|
|
|
|
// unlimited
|
|
// Required: true
|
|
Unlimited *bool `json:"unlimited"`
|
|
}
|
|
|
|
// Validate validates this descriptive limit
|
|
func (m *DescriptiveLimit) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validatePeriod(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateQuantity(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateUnit(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateUnlimited(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
var descriptiveLimitTypePeriodPropEnum []any
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["none","day","month","billing_period","lifetime"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
descriptiveLimitTypePeriodPropEnum = append(descriptiveLimitTypePeriodPropEnum, v)
|
|
}
|
|
}
|
|
|
|
const (
|
|
|
|
// DescriptiveLimitPeriodNone captures enum value "none"
|
|
DescriptiveLimitPeriodNone string = "none"
|
|
|
|
// DescriptiveLimitPeriodDay captures enum value "day"
|
|
DescriptiveLimitPeriodDay string = "day"
|
|
|
|
// DescriptiveLimitPeriodMonth captures enum value "month"
|
|
DescriptiveLimitPeriodMonth string = "month"
|
|
|
|
// DescriptiveLimitPeriodBillingPeriod captures enum value "billing_period"
|
|
DescriptiveLimitPeriodBillingPeriod string = "billing_period"
|
|
|
|
// DescriptiveLimitPeriodLifetime captures enum value "lifetime"
|
|
DescriptiveLimitPeriodLifetime string = "lifetime"
|
|
)
|
|
|
|
// prop value enum
|
|
func (m *DescriptiveLimit) validatePeriodEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, descriptiveLimitTypePeriodPropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *DescriptiveLimit) validatePeriod(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("period", "body", m.Period); err != nil {
|
|
return err
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validatePeriodEnum("period", "body", *m.Period); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *DescriptiveLimit) validateQuantity(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.Quantity) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.MinLength("quantity", "body", *m.Quantity, 1); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.MaxLength("quantity", "body", *m.Quantity, 21); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.Pattern("quantity", "body", *m.Quantity, `^(0|[1-9][0-9]{0,13})(\.[0-9]{1,6})?$`); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *DescriptiveLimit) validateUnit(formats strfmt.Registry) error {
|
|
if typeutils.IsZero(m.Unit) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.MaxLength("unit", "body", *m.Unit, 40); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *DescriptiveLimit) validateUnlimited(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("unlimited", "body", m.Unlimited); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validates this descriptive limit based on context it is used
|
|
func (m *DescriptiveLimit) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *DescriptiveLimit) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return jsonutils.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *DescriptiveLimit) UnmarshalBinary(b []byte) error {
|
|
var res DescriptiveLimit
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|