gitlab.com/evatix-go/core@v1.3.55/corevalidator/LineNumber.go (about) 1 package corevalidator 2 3 import ( 4 "errors" 5 6 "gitlab.com/evatix-go/core/constants" 7 "gitlab.com/evatix-go/core/errcore" 8 ) 9 10 type LineNumber struct { 11 LineNumber int `json:"LineNumber,omitempty"` // -1 means no checking in line 12 } 13 14 func (it *LineNumber) HasLineNumber() bool { 15 return it.LineNumber > constants.InvalidValue 16 } 17 18 func (it *LineNumber) IsMatch(lineNumber int) bool { 19 if lineNumber == constants.InvalidValue || 20 it.LineNumber == constants.InvalidValue { 21 return true 22 } 23 24 return it.LineNumber == lineNumber 25 } 26 27 func (it *LineNumber) VerifyError( 28 lineNumber int, 29 ) error { 30 if it.IsMatch(lineNumber) { 31 return nil 32 } 33 34 msg := errcore.Expecting( 35 "Line Number didn't match", 36 it.LineNumber, 37 lineNumber) 38 39 return errors.New(msg) 40 }