// AgainstSchema validates the specified data with the provided schema, when no schema // is provided it uses the json schema as default func AgainstSchema(schema *spec.Schema, data interface{}, formats strfmt.Registry) error { res := validate.NewSchemaValidator(schema, nil, "", formats).Validate(data) if res.HasErrors() { return errors.CompositeValidationError(res.Errors...) } return nil }
func newUntypedParamBinder(param spec.Parameter, spec *spec.Swagger, formats strfmt.Registry) *untypedParamBinder { binder := new(untypedParamBinder) binder.Name = param.Name binder.parameter = ¶m binder.formats = formats if param.In != "body" { binder.validator = validate.NewParamValidator(¶m, formats) } else { binder.validator = validate.NewSchemaValidator(param.Schema, spec, param.Name, formats) } return binder }