当前位置: 首页>>代码示例>>Golang>>正文


Golang content.NewValidationError函数代码示例

本文整理汇总了Golang中github.com/urandom/readeef/content.NewValidationError函数的典型用法代码示例。如果您正苦于以下问题:Golang NewValidationError函数的具体用法?Golang NewValidationError怎么用?Golang NewValidationError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewValidationError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Validate

func (t *Tag) Validate() error {
	if t.data.Value == "" {
		return content.NewValidationError(errors.New("Tag has no value"))
	}

	if t.user == nil || t.user.Data().Login == "" {
		return content.NewValidationError(errors.New("Tag has no user"))
	}

	return nil
}
开发者ID:urandom,项目名称:readeef,代码行数:11,代码来源:tag.go

示例2: Validate

func (f Feed) Validate() error {
	if f.data.Link == "" {
		return content.NewValidationError(errors.New("Feed has no link"))
	}

	if u, err := url.Parse(f.data.Link); err != nil || !u.IsAbs() {
		return content.NewValidationError(errors.New("Feed has no link"))
	}

	return nil
}
开发者ID:urandom,项目名称:readeef,代码行数:11,代码来源:feed.go

示例3: Validate

func (a Article) Validate() error {
	if a.data.FeedId == 0 {
		return content.NewValidationError(errors.New("Article has no feed id"))
	}

	if !a.data.Guid.Valid && a.data.Link == "" {
		return content.NewValidationError(errors.New("Article has no guid or link"))
	}

	return nil
}
开发者ID:urandom,项目名称:readeef,代码行数:11,代码来源:article.go

示例4: Validate

func (u User) Validate() error {
	if u.data.Login == "" {
		return content.NewValidationError(errors.New("Invalid user login"))
	}
	if u.data.Email != "" {
		if _, err := mail.ParseAddress(u.String()); err != nil {
			return content.NewValidationError(err)
		}
	}

	return nil
}
开发者ID:RavenB,项目名称:readeef,代码行数:12,代码来源:user.go

示例5: Validate

func (s *Subscription) Validate() error {
	if s.data.Link == "" {
		return content.NewValidationError(errors.New("No subscription link"))
	}

	if u, err := url.Parse(s.data.Link); err != nil || !u.IsAbs() {
		return content.NewValidationError(errors.New("Invalid subscription link"))
	}

	if s.data.FeedId == 0 {
		return content.NewValidationError(errors.New("Invalid feed id"))
	}

	return nil
}
开发者ID:urandom,项目名称:readeef,代码行数:15,代码来源:subscription.go

示例6: UnreadArticles

func (uf *UserFeed) UnreadArticles(paging ...int) (ua []content.UserArticle) {
	if uf.HasErr() {
		return
	}

	if err := uf.Validate(); err != nil {
		uf.Err(err)
		return
	}

	id := uf.Data().Id
	if id == 0 {
		uf.Err(content.NewValidationError(errors.New("Invalid feed id")))
		return
	}

	uf.logger.Infof("Getting unread articles for feed %d\n", id)

	articles := uf.getArticles("ar.article_id IS NULL", "", paging...)
	ua = make([]content.UserArticle, len(articles))
	for i := range articles {
		ua[i] = articles[i]
	}

	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:26,代码来源:feed.go

示例7: Validate

func (ae ArticleExtract) Validate() error {
	if ae.data.ArticleId == 0 {
		return content.NewValidationError(errors.New("Article extract has no article id"))
	}

	return nil
}
开发者ID:urandom,项目名称:readeef,代码行数:7,代码来源:article_extract.go

示例8: Extract

func (a *Article) Extract() (ae content.ArticleExtract) {
	ae = a.Repo().ArticleExtract()
	if a.HasErr() {
		ae.Err(a.Err())
		return
	}

	id := a.Data().Id
	if id == 0 {
		a.Err(content.NewValidationError(errors.New("Invalid article id")))
		return
	}

	a.logger.Infof("Getting article '%d' extract\n", id)

	var i data.ArticleExtract
	if err := a.db.Get(&i, a.db.SQL().Article.GetExtract, id); err != nil {
		if err == sql.ErrNoRows {
			err = content.ErrNoContent
		}
		ae.Err(err)
	}

	i.ArticleId = id
	ae.Data(i)

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:28,代码来源:article.go

示例9: Thumbnail

func (a *Article) Thumbnail() (at content.ArticleThumbnail) {
	at = a.Repo().ArticleThumbnail()
	if a.HasErr() {
		at.Err(a.Err())
		return
	}

	id := a.Data().Id
	if id == 0 {
		a.Err(content.NewValidationError(errors.New("Invalid article id")))
		return
	}

	a.logger.Infof("Getting article '%d' thumbnail\n", id)

	var i data.ArticleThumbnail
	if err := a.db.Get(&i, a.db.SQL().Article.GetThumbnail, id); err != nil {
		if err == sql.ErrNoRows {
			err = content.ErrNoContent
		}
		at.Err(err)
	}

	i.ArticleId = id
	at.Data(i)

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:28,代码来源:article.go

示例10: Subscription

func (f *Feed) Subscription() (s content.Subscription) {
	s = f.Repo().Subscription()
	if f.HasErr() {
		s.Err(f.Err())
		return
	}

	id := f.Data().Id
	if id == 0 {
		f.Err(content.NewValidationError(errors.New("Invalid feed id")))
		return
	}

	f.logger.Infof("Getting subcription for feed %d\n", id)

	var in data.Subscription
	if err := f.db.Get(&in, f.db.SQL().Feed.GetHubbubSubscription, id); err != nil {
		if err == sql.ErrNoRows {
			err = content.ErrNoContent
		}
		s.Err(err)
	}

	in.FeedId = id
	s.Data(in)

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:28,代码来源:feed.go

示例11: Validate

func (asc ArticleScores) Validate() error {
	if asc.data.ArticleId == 0 {
		return content.NewValidationError(errors.New("Article scores has no article id"))
	}

	return nil
}
开发者ID:urandom,项目名称:readeef,代码行数:7,代码来源:article_scores.go

示例12: Scores

func (sa *ScoredArticle) Scores() (asc content.ArticleScores) {
	asc = sa.Repo().ArticleScores()
	if sa.HasErr() {
		asc.Err(sa.Err())
		return
	}

	id := sa.Data().Id
	if id == 0 {
		sa.Err(content.NewValidationError(errors.New("Invalid article id")))
		return
	}

	sa.logger.Infof("Getting article '%d' scores\n", id)

	var i data.ArticleScores
	if err := sa.db.Get(&i, sa.db.SQL("get_article_scores"), id); err != nil {
		if err == sql.ErrNoRows {
			err = content.ErrNoContent
		}
		asc.Err(err)
	}

	i.ArticleId = id
	asc.Data(i)

	return
}
开发者ID:RavenB,项目名称:readeef,代码行数:28,代码来源:article.go

示例13: Users

func (f *Feed) Users() (u []content.User) {
	if f.HasErr() {
		return
	}

	id := f.Data().Id
	if id == 0 {
		f.Err(content.NewValidationError(errors.New("Invalid feed id")))
		return
	}

	f.logger.Infof("Getting users for feed %d\n", id)

	var in []data.User
	if err := f.db.Select(&in, f.db.SQL().Feed.GetUsers, id); err != nil {
		f.Err(err)
		return
	}

	u = make([]content.User, len(in))
	for i := range in {
		u[i] = f.Repo().User()
		u[i].Data(in[i])

		if u[i].HasErr() {
			f.Err(u[i].Err())
			return
		}
	}

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:32,代码来源:feed.go

示例14: Validate

func (d Domain) Validate() error {
	if d.url == nil {
		return content.NewValidationError(errors.New("No url"))
	}

	return nil
}
开发者ID:RavenB,项目名称:readeef,代码行数:7,代码来源:domain.go

示例15: Articles

func (uf *UserFeed) Articles(o ...data.ArticleQueryOptions) (ua []content.UserArticle) {
	if uf.HasErr() {
		return
	}

	if err := uf.Validate(); err != nil {
		uf.Err(err)
		return
	}

	id := uf.Data().Id
	if id == 0 {
		uf.Err(content.NewValidationError(errors.New("Invalid feed id")))
		return
	}

	var opts data.ArticleQueryOptions
	if len(o) > 0 {
		opts = o[0]
	}

	uf.logger.Infof("Getting articles for feed %d with options: %#v\n", id, opts)

	where := "uf.feed_id = $2"

	u := uf.User()
	ua = getArticles(u, uf.db, uf.logger, opts, uf, "", where, []interface{}{uf.Data().Id})

	if u.HasErr() {
		uf.Err(u.Err())
	}

	return
}
开发者ID:urandom,项目名称:readeef,代码行数:34,代码来源:feed.go


注:本文中的github.com/urandom/readeef/content.NewValidationError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。