Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotationsValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func GetPlatformValidator() *validate.PlatformValidator
- func MmolOrMgUnitsValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func MmolUnitsValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func NonZuluPastTimeStringValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func OffsetOrZuluPastTimeStringValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func OffsetPastTimeStringValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func PayloadValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func TimezoneOffsetValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- func ZuluPastTimeStringValidator(v *validator.Validate, topStruct reflect.Value, ...) bool
- type Allowed
- type AllowedDate
- type AllowedFloatRange
- type AllowedIntRange
- type Base
- type BloodGlucoseValidation
- func (b *BloodGlucoseValidation) SetValueAllowedToBeEmpty(valueAllowedToBeEmpty bool) *BloodGlucoseValidation
- func (b *BloodGlucoseValidation) SetValueErrorPath(valueErrorPath string) *BloodGlucoseValidation
- func (b *BloodGlucoseValidation) ValidateAndConvertBloodGlucoseValue(errs validate.ErrorProcessing) (*float64, *string)
- type DateDatumField
- type Datum
- func (d Datum) ToArray(fieldName string, errs validate.ErrorProcessing) []interface{}
- func (d Datum) ToBool(fieldName string, errs validate.ErrorProcessing) *bool
- func (d Datum) ToFloat64(fieldName string, errs validate.ErrorProcessing) *float64
- func (d Datum) ToInt(fieldName string, errs validate.ErrorProcessing) *int
- func (d Datum) ToMap(fieldName string, errs validate.ErrorProcessing) map[string]interface{}
- func (d Datum) ToObject(fieldName string, errs validate.ErrorProcessing) interface{}
- func (d Datum) ToString(fieldName string, errs validate.ErrorProcessing) *string
- func (d Datum) ToStringArray(fieldName string, errs validate.ErrorProcessing) []string
- func (d Datum) ToTime(fieldName string, errs validate.ErrorProcessing) *time.Time
- type DatumArray
- type DatumField
- type DatumFieldInformation
- type ExpectedErrorDetails
- type FloatDatumField
- type IntDatumField
- type Internal
- type TestingHelper
Constants ¶
View Source
const ( InvalidTypeTitle = "Invalid type" InvalidDataTitle = "Invalid data" CurrentSchemaVersion = 3 )
Variables ¶
View Source
var ( //InternalFields are what we only use internally in the service and don't wish to return to any clients InternalFields = []string{ "_groupId", "_active", "_schemaVersion", "_version", "createdTime", } BaseUserIDField = DatumField{Name: "userId"} BaseGroupIDField = DatumField{Name: "_groupId"} BaseSubTypeField = DatumField{Name: "subType"} BaseTypeField = DatumFieldInformation{ DatumField: &DatumField{Name: "type"}, Tag: "required", Message: "This is a required field", } BaseDeviceIDField = DatumFieldInformation{ DatumField: &DatumField{Name: "deviceId"}, Tag: "required", Message: "This is a required field", } )
View Source
var ( MmolOrMgUnitsField = DatumFieldInformation{ DatumField: &DatumField{Name: "units"}, Tag: "mmolmgunits", Message: fmt.Sprintf("Must be one of %s, %s", mmol, mg), Allowed: Allowed{ "mmol/l": true, "mg/dl": true, // contains filtered or unexported fields }, } MmolUnitsField = DatumFieldInformation{ DatumField: &DatumField{Name: "units"}, Tag: "mmolunits", Message: fmt.Sprintf("Must be %s", mmol), Allowed: Allowed{ "mmol/l": true, // contains filtered or unexported fields }, } BloodGlucoseValueField = FloatDatumField{ DatumField: &DatumField{Name: "value"}, Tag: "bloodglucosevalue", } )
View Source
var ( ZuluTimeStringField = DateDatumField{ DatumField: &DatumField{Name: "time"}, Tag: "zuluTimeString", Message: "An ISO 8601-formatted UTC timestamp with a final Z for 'Zulu' time e.g 2013-05-04T03:58:44.584Z", AllowedDate: &AllowedDate{ Format: "2006-01-02T15:04:05Z", LowerLimit: "2007-01-01T00:00:00Z", AllowedFuture: false, }, } NonZuluTimeStringField = DateDatumField{ DatumField: &DatumField{Name: "time"}, Tag: "nonZuluTimeString", Message: "An ISO 8601 formatted timestamp without any timezone offset information e.g 2013-05-04T03:58:44.584", AllowedDate: &AllowedDate{ Format: "2006-01-02T15:04:05", LowerLimit: "2007-01-01T00:00:00", AllowedFuture: true, }, } OffsetTimeStringField = DateDatumField{ DatumField: &DatumField{Name: "time"}, Tag: "offsetTimeString", Message: "An ISO 8601-formatted timestamp including a timezone offset from UTC e.g 2013-05-04T03:58:44-08:00", AllowedDate: &AllowedDate{ Format: "2006-01-02T15:04:05-07:00", LowerLimit: "2007-01-01T00:00:00-00:00", AllowedFuture: false, }, } OffsetOrZuluTimeStringField = DateDatumField{ DatumField: &DatumField{Name: "time"}, Tag: "offsetOrZuluTimeString", Message: "An ISO 8601-formatted timestamp including either a timezone offset from UTC OR converted to UTC with a final Z for 'Zulu' time. e.g.2013-05-04T03:58:44.584Z OR 2013-05-04T03:58:44-08:00", } )
Functions ¶
func AnnotationsValidator ¶
func GetPlatformValidator ¶
func GetPlatformValidator() *validate.PlatformValidator
func MmolOrMgUnitsValidator ¶
func MmolUnitsValidator ¶
func PayloadValidator ¶
func TimezoneOffsetValidator ¶
Types ¶
type AllowedDate ¶
type AllowedFloatRange ¶
type AllowedIntRange ¶
type Base ¶
type Base struct { ID string `json:"id" bson:"id" valid:"required"` UserID *string `json:"userId" bson:"userId" valid:"required"` DeviceID *string `json:"deviceId" bson:"deviceId" valid:"required"` Time *string `json:"time" bson:"time" valid:"offsetOrZuluTimeString"` Type *string `json:"type" bson:"type" valid:"required"` UploadID *string `json:"uploadId" bson:"uploadId" valid:"-"` //optional data DeviceTime *string `json:"deviceTime,omitempty" bson:"deviceTime,omitempty" valid:"omitempty,nonZuluTimeString"` TimezoneOffset *int `json:"timezoneOffset,omitempty" bson:"timezoneOffset,omitempty" valid:"omitempty,timezoneoffset"` ConversionOffset *int `json:"conversionOffset,omitempty" bson:"conversionOffset,omitempty" valid:"omitempty,required"` ClockDriftOffset *int `json:"clockDriftOffset,omitempty" bson:"clockDriftOffset,omitempty" valid:"omitempty,required"` Payload interface{} `json:"payload,omitempty" bson:"payload,omitempty" valid:"omitempty,payload"` Annotations []interface{} `json:"annotations,omitempty" bson:"annotations,omitempty" valid:"omitempty,annotations"` //used for versioning and de-deping Internal `bson:",inline"` // contains filtered or unexported fields }
type BloodGlucoseValidation ¶
type BloodGlucoseValidation struct { Value *float64 Units *string // contains filtered or unexported fields }
func NewBloodGlucoseValidation ¶
func NewBloodGlucoseValidation(val *float64, units *string) *BloodGlucoseValidation
func (*BloodGlucoseValidation) SetValueAllowedToBeEmpty ¶
func (b *BloodGlucoseValidation) SetValueAllowedToBeEmpty(valueAllowedToBeEmpty bool) *BloodGlucoseValidation
func (*BloodGlucoseValidation) SetValueErrorPath ¶
func (b *BloodGlucoseValidation) SetValueErrorPath(valueErrorPath string) *BloodGlucoseValidation
func (*BloodGlucoseValidation) ValidateAndConvertBloodGlucoseValue ¶
func (b *BloodGlucoseValidation) ValidateAndConvertBloodGlucoseValue(errs validate.ErrorProcessing) (*float64, *string)
type DateDatumField ¶
type DateDatumField struct { *DatumField Tag validate.ValidationTag Message string *AllowedDate }
type Datum ¶
type Datum map[string]interface{}
func (Datum) ToArray ¶
func (d Datum) ToArray(fieldName string, errs validate.ErrorProcessing) []interface{}
func (Datum) ToFloat64 ¶
func (d Datum) ToFloat64(fieldName string, errs validate.ErrorProcessing) *float64
func (Datum) ToMap ¶
func (d Datum) ToMap(fieldName string, errs validate.ErrorProcessing) map[string]interface{}
func (Datum) ToObject ¶
func (d Datum) ToObject(fieldName string, errs validate.ErrorProcessing) interface{}
func (Datum) ToString ¶
func (d Datum) ToString(fieldName string, errs validate.ErrorProcessing) *string
func (Datum) ToStringArray ¶
func (d Datum) ToStringArray(fieldName string, errs validate.ErrorProcessing) []string
type DatumArray ¶
type DatumArray []Datum
type DatumField ¶
type DatumField struct {
Name string
}
type DatumFieldInformation ¶
type DatumFieldInformation struct { *DatumField Tag validate.ValidationTag Message string Allowed }
type ExpectedErrorDetails ¶
type FloatDatumField ¶
type FloatDatumField struct { *DatumField Tag validate.ValidationTag Message string *AllowedFloatRange }
type IntDatumField ¶
type IntDatumField struct { *DatumField Tag validate.ValidationTag Message string *AllowedIntRange }
type Internal ¶
type Internal struct { CreatedTime string `json:"createdTime" bson:"createdTime" valid:"zuluTimeString"` GroupID string `json:"-" bson:"_groupId" valid:"required"` ActiveFlag bool `json:"-" bson:"_active" valid:"required"` SchemaVersion int `json:"-" bson:"_schemaVersion" valid:"required,min=0"` Version int `json:"-" bson:"_version,omitempty" valid:"-"` }
Internal are existing fields used for versioning and de-deping
type TestingHelper ¶
type TestingHelper struct {
ErrorProcessing validate.ErrorProcessing
}
func NewTestingHelper ¶
func NewTestingHelper() *TestingHelper
func (*TestingHelper) ErrorIsExpected ¶
func (t *TestingHelper) ErrorIsExpected(builtType interface{}, expected ExpectedErrorDetails) error
func (*TestingHelper) HasExpectedErrors ¶
func (t *TestingHelper) HasExpectedErrors(builtType interface{}, expected map[string]ExpectedErrorDetails) error
func (*TestingHelper) ValidDataType ¶
func (t *TestingHelper) ValidDataType(builtType interface{}) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.