validate

package
v0.0.0-...-6f7621a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package validate provides validation logic for checking over a local knowledge base.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFilenameValidator

func NewFilenameValidator() filenameValidator

NewFilenameValidator returns a filenameValidator type.

Types

type Error

type Error uint8

Error allows for sentinel errors via enums.

const (
	// ErrFailedRegexMatch is a sentinel error for when the check fails due to
	// regexp.MatchString returning an error, commonly caused by an invalid regex
	// pattern.
	ErrFailedRegexMatch Error = iota

	// ErrInsufficientNumberOfFilenameParts is a sentinel error for when the check
	//  fails due to the filename not having at least one part.
	ErrInsufficientNumberOfFilenameParts

	// ErrInvalidFilenameFormat is a sentinel error for when the check fails due
	// to a note filename using the incorrect format.
	ErrInvalidFilenameFormat

	// ErrMissingMarkdownFileExtension is a sentinel error for when the check
	// fails due to the filename not ending with the ".md" markdown file
	// extension.
	ErrMissingMarkdownFileExtension

	// ErrUnrecognisedBaseSchemaType is a sentinel error for when the check fails
	// due to the filename using a base schema type which is not valid/known.
	ErrUnrecognisedBaseSchemaType
)

func (Error) Error

func (e Error) Error() string

Error implements the errors.Error interface.

type Validator

type Validator interface {
	Validate(filename string, filenameWithoutExtension string) []error
}

Validator is an interface for all validator types to derive from, it allows validation logic to be separate from the model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL