Skip to content
Snippets Groups Projects
Commit 0510c590 authored by jensilo's avatar jensilo
Browse files

remove unnecessary interface

parent fe08f54f
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ var ( ...@@ -23,7 +23,7 @@ var (
ErrNotAString = errors.New("eiffel.parser.error.not-a-string") ErrNotAString = errors.New("eiffel.parser.error.not-a-string")
) )
// BasicTemplate is the basic EIFFEL template. It is parsable by implementing the template.ParsableTemplate interface. // BasicTemplate is the basic EIFFEL template.
// //
// A basic template is a template that defines a set of rules and a set of variants. // A basic template is a template that defines a set of rules and a set of variants.
// Each variant contains rules that are to be applied to a requirement in the parsing step to validate the requirement. // Each variant contains rules that are to be applied to a requirement in the parsing step to validate the requirement.
...@@ -182,7 +182,7 @@ func RuleParsers() *RuleParserProvider { ...@@ -182,7 +182,7 @@ func RuleParsers() *RuleParserProvider {
} }
} }
// Parse implements the template.ParsableTemplate interface for the BasicTemplate. It is used to parse requirements in the form of segments. // Parse is used to parse requirements in the form of segments.
// Each segment is a part of the requirement that is to be parsed. For the EIFFEL basic template (EBT), each segment is an input from auto-generated // Each segment is a part of the requirement that is to be parsed. For the EIFFEL basic template (EBT), each segment is an input from auto-generated
// input field based on the rules defined in the template. Therefore, each segment will be validated by the corresponding rule. // input field based on the rules defined in the template. Therefore, each segment will be validated by the corresponding rule.
// It is recommended to validate the template before parsing requirements. // It is recommended to validate the template before parsing requirements.
......
package parser package parser
import ( import (
"context"
"github.com/org-harmony/harmony/src/core/trans" "github.com/org-harmony/harmony/src/core/trans"
"github.com/org-harmony/harmony/src/core/validation"
) )
const ( const (
...@@ -54,12 +52,6 @@ type ParsingLog struct { ...@@ -54,12 +52,6 @@ type ParsingLog struct {
Downgrade bool Downgrade bool
} }
// ParsableTemplate is a template that can be validated and parsed.
type ParsableTemplate interface {
Validate(v validation.V) []error
Parse(ctx context.Context, variation string, segments ...ParsingSegment) (ParsingResult, error)
}
// String on ParsingLog returns the message of the log. // String on ParsingLog returns the message of the log.
func (l ParsingLog) String() string { func (l ParsingLog) String() string {
return l.Message return l.Message
......
...@@ -18,8 +18,7 @@ var ( ...@@ -18,8 +18,7 @@ var (
) )
// ValidateTemplateConfigEvent is published to validate a template config. It allows for other modules to validate // ValidateTemplateConfigEvent is published to validate a template config. It allows for other modules to validate
// specific parts or entire templates based on their own rules. This is helpful if a module defines a template.ParsableTemplate // specific parts or entire templates based on their own rules. This is helpful if a template should be validated against the rules of the parser.
// and the template should be validated against the rules of the parser.
type ValidateTemplateConfigEvent struct { type ValidateTemplateConfigEvent struct {
Config string Config string
TemplateType string TemplateType string
...@@ -29,8 +28,7 @@ type ValidateTemplateConfigEvent struct { ...@@ -29,8 +28,7 @@ type ValidateTemplateConfigEvent struct {
// ValidateTemplateToCreate validates the template to create against the template set's rules and publishes an event // ValidateTemplateToCreate validates the template to create against the template set's rules and publishes an event
// to validate the template config. The event allows for other modules to validate specific parts or entire templates // to validate the template config. The event allows for other modules to validate specific parts or entire templates
// based on their own rules. This is helpful if a module defines a template.ParsableTemplate and the template should be // based on their own rules. This is helpful if a template should be validated against the rules of the parser.
// validated against the rules of the parser.
func ValidateTemplateToCreate(toCreate *ToCreate, validator validation.V, em event.Manager, logger trace.Logger) ([]error, error) { func ValidateTemplateToCreate(toCreate *ToCreate, validator validation.V, em event.Manager, logger trace.Logger) ([]error, error) {
err, validationErrs := validator.ValidateStruct(toCreate) err, validationErrs := validator.ValidateStruct(toCreate)
if err != nil { if err != nil {
...@@ -52,8 +50,7 @@ func ValidateTemplateToCreate(toCreate *ToCreate, validator validation.V, em eve ...@@ -52,8 +50,7 @@ func ValidateTemplateToCreate(toCreate *ToCreate, validator validation.V, em eve
// ValidateTemplateToUpdate validates the template to update against the template set's rules and publishes an event // ValidateTemplateToUpdate validates the template to update against the template set's rules and publishes an event
// to validate the template config. The event allows for other modules to validate specific parts or entire templates // to validate the template config. The event allows for other modules to validate specific parts or entire templates
// based on their own rules. This is helpful if a module defines a template.ParsableTemplate and the template should be // based on their own rules. This is helpful if a template should be validated against the rules of the parser.
// validated against the rules of the parser.
func ValidateTemplateToUpdate(toUpdate *ToUpdate, validator validation.V, em event.Manager, logger trace.Logger) ([]error, error) { func ValidateTemplateToUpdate(toUpdate *ToUpdate, validator validation.V, em event.Manager, logger trace.Logger) ([]error, error) {
err, validationErrs := validator.ValidateStruct(toUpdate) err, validationErrs := validator.ValidateStruct(toUpdate)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment