Skip to content

Commit

Permalink
export the Validate method on mapping objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoch committed Mar 28, 2016
1 parent 639fb1a commit 2b82387
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func newMemIndex(indexType string, mapping *IndexMapping) (*indexImpl, error) {

func newIndexUsing(path string, mapping *IndexMapping, indexType string, kvstore string, kvconfig map[string]interface{}) (*indexImpl, error) {
// first validate the mapping
err := mapping.validate()
err := mapping.Validate()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *inde
rv.open = true

// validate the mapping
err = im.validate()
err = im.Validate()
if err != nil {
// note even if the mapping is invalid
// we still return an open usable index
Expand Down
4 changes: 2 additions & 2 deletions mapping_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type DocumentMapping struct {
DefaultAnalyzer string `json:"default_analyzer"`
}

func (dm *DocumentMapping) validate(cache *registry.Cache) error {
func (dm *DocumentMapping) Validate(cache *registry.Cache) error {
var err error
if dm.DefaultAnalyzer != "" {
_, err := cache.AnalyzerNamed(dm.DefaultAnalyzer)
Expand All @@ -48,7 +48,7 @@ func (dm *DocumentMapping) validate(cache *registry.Cache) error {
}
}
for _, property := range dm.Properties {
err = property.validate(cache)
err = property.Validate(cache)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions mapping_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func NewIndexMapping() *IndexMapping {

// Validate will walk the entire structure ensuring the following
// explicitly named and default analyzers can be built
func (im *IndexMapping) validate() error {
func (im *IndexMapping) Validate() error {
_, err := im.cache.AnalyzerNamed(im.DefaultAnalyzer)
if err != nil {
return err
Expand All @@ -253,12 +253,12 @@ func (im *IndexMapping) validate() error {
if err != nil {
return err
}
err = im.DefaultMapping.validate(im.cache)
err = im.DefaultMapping.Validate(im.cache)
if err != nil {
return err
}
for _, docMapping := range im.TypeMapping {
err = docMapping.validate(im.cache)
err = docMapping.Validate(im.cache)
if err != nil {
return err
}
Expand Down

0 comments on commit 2b82387

Please sign in to comment.