type ValueValidator … type basicCommonValidator … func (b *basicCommonValidator) SetPath(path string) { … } func (b *basicCommonValidator) Applies(source interface{ … } func (b *basicCommonValidator) Validate(data interface{ … } type numberValidator … func (n *numberValidator) SetPath(path string) { … } func (n *numberValidator) Applies(source interface{ … } // Validate provides a validator for generic JSON numbers, // // By default, numbers are internally represented as float64. // Formats float, or float32 may alter this behavior by mapping to float32. // A special validation process is followed for integers, with optional "format": // this is an attempt to provide a validation with native types. // // NOTE: since the constraint specified (boundary, multipleOf) is unmarshalled // as float64, loss of information remains possible (e.g. on very large integers). // // Since this value directly comes from the unmarshalling, it is not possible // at this stage of processing to check further and guarantee the correctness of such values. // // Normally, the JSON Number.MAX_SAFE_INTEGER (resp. Number.MIN_SAFE_INTEGER) // would check we do not get such a loss. // // If this is the case, replace AddErrors() by AddWarnings() and IsValid() by !HasWarnings(). // // TODO: consider replacing boundary check errors by simple warnings. // // TODO: default boundaries with MAX_SAFE_INTEGER are not checked (specific to json.Number?) func (n *numberValidator) Validate(val interface{ … } type stringValidator … func (s *stringValidator) SetPath(path string) { … } func (s *stringValidator) Applies(source interface{ … } func (s *stringValidator) Validate(val interface{ … }