示例#1
0
文件: validator.go 项目: apognu/xml
package atom

import (
	"fmt"

	xmlutils "github.com/apognu/xml/utils"
)

var (
	IsAbsoluteIRI  = xmlutils.IsValidAbsoluteIri(IriNotAbsolute)
	IsValidIRI     = xmlutils.IsValidIri(IriNotValid)
	IsValidLength  = xmlutils.IsValidNumber(NotPositiveNumber)
	IsValidMIME    = xmlutils.IsValidMIME(IsNotMIME)
	IsXMLMediaType = xmlutils.IsValidXMLMediaType(NotXMLMediaType)
)

func relIsIANA(name, s string) xmlutils.ParserError {
	if s == "alternate" || s == "related" || s == "self" || s == "enclosure" || s == "via" {
		return nil
	}

	return xmlutils.NewError(RelNotValid, fmt.Sprintf("rel is not valid: %s", s))
}

func contentTypeIsValid(name, s string) xmlutils.ParserError {
	if s == "text" || s == "html" || s == "xhtml" {
		return xmlutils.NewError(ContentTypeIsNotValid, "type not valid")
	}

	return nil
}
示例#2
0
文件: link.go 项目: apognu/xml
func newCountAttr() extension.Attr {
	c := Count{extension.NewBasicAttr(_count, xmlutils.IsValidNumber(atom.NotPositiveNumber))}

	return &c
}