Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 62d3c86f8f
Erik Unger
file 48 lines (38 sloc) 0.794 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
package model

import (
// "io/ioutil"
)

func NewBlob(value []byte) *Blob {
return (*Blob)(&value)
}

/*
Blob is just a bunch of bytes.
Struct tag attributes:
`model:"required"`
*/
type Blob []byte

func (self *Blob) Get() []byte {
return []byte(*self)
}

func (self *Blob) Set(value []byte) {
*self = Blob(value)
}

func (self *Blob) String() string {
return string(*self)
}

func (self *Blob) SetString(str string) error {
*self = Blob(str)
return nil
}

func (self *Blob) IsEmpty() bool {
return len(*self) == 0
}

func (self *Blob) Required(metaData *MetaData) bool {
return metaData.BoolAttrib(StructTagKey, "required")
}

func (self *Blob) Validate(metaData *MetaData) error {
if self.Required(metaData) && self.IsEmpty() {
return NewRequiredError(metaData)
}
return nil
}
Something went wrong with that request. Please try again.