| 1 |
package schema_validation |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/pb33f/libopenapi" |
| 7 |
derrors "github.com/pb33f/libopenapi-validator/errors" |
| 8 |
"github.com/pb33f/libopenapi-validator/helpers" |
| 9 |
"github.com/pb33f/libopenapi/datamodel/high/base" |
| 10 |
v3 "github.com/pb33f/libopenapi/datamodel/high/v3" |
| 11 |
"github.com/pb33f/libopenapi/orderedmap" |
| 12 |
"github.com/stretchr/testify/assert" |
| 13 |
) |
| 14 |
|
| 15 |
func TestIsURLEncodedContentType(t *testing.T) { |
| 16 |
tests := []struct { |
| 17 |
input string |
| 18 |
expected bool |
| 19 |
}{ |
| 20 |
{"application/x-www-form-urlencoded", true}, |
| 21 |
{"APPLICATION/X-WWW-FORM-URLENCODED", true}, |
| 22 |
{"application/x-www-form-urlencoded; charset=utf-8", true}, |
| 23 |
{"application/json", false}, |
| 24 |
{"", false}, |
| 25 |
} |
| 26 |
|
| 27 |
for _, tt := range tests { |
| 28 |
assert.Equal(t, tt.expected, IsURLEncodedContentType(tt.input)) |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
func TestUnflattenValues(t *testing.T) { |
| 33 |
vals := map[string][]string{ |
| 34 |
"simple": {"val"}, |
| 35 |
"arr[]": {"1", "2"}, |
| 36 |
"obj[prop]": {"v1"}, |
| 37 |
"deep[a][b]": {"v2"}, |
| 38 |
"double": {"1", "2"}, |
| 39 |
} |
| 40 |
|
| 41 |
result := unflattenValues(vals) |
| 42 |
|
| 43 |
assert.Equal(t, "val", result["simple"]) |
| 44 |
assert.Equal(t, []string{"1", "2"}, result["arr"]) |
| 45 |
assert.Equal(t, []string{"1", "2"}, result["double"]) |
| 46 |
|
| 47 |
obj, ok := result["obj"].(map[string]any) |
| 48 |
assert.True(t, ok) |
| 49 |
assert.Equal(t, "v1", obj["prop"]) |
| 50 |
|
| 51 |
deep, ok := result["deep"].(map[string]any) |
| 52 |
assert.True(t, ok) |
| 53 |
inner, ok := deep["a"].(map[string]any) |
| 54 |
assert.True(t, ok) |
| 55 |
assert.Equal(t, "v2", inner["b"]) |
| 56 |
} |
| 57 |
|
| 58 |
func TestBuildDeepMap_BranchCoverage(t *testing.T) { |
| 59 |
root := make(map[string]any) |
| 60 |
|
| 61 |
root["collision"] = "string_value" |
| 62 |
|
| 63 |
buildDeepMap(root, "collision[sub]", []string{"val"}) |
| 64 |
|
| 65 |
assert.Equal(t, "string_value", root["collision"]) |
| 66 |
|
| 67 |
root2 := make(map[string]any) |
| 68 |
buildDeepMap(root2, "arr[key]", []string{"a", "b"}) |
| 69 |
|
| 70 |
inner := root2["arr"].(map[string]any) |
| 71 |
assert.Equal(t, []string{"a", "b"}, inner["key"]) |
| 72 |
} |
| 73 |
|
| 74 |
func TestTransformURLEncodedToSchemaJSON(t *testing.T) { |
| 75 |
t.Run("Malformed URL Encoding", func(t *testing.T) { |
| 76 |
res, errs := TransformURLEncodedToSchemaJSON("bad_encoding=%zz", nil, nil) |
| 77 |
assert.Nil(t, res) |
| 78 |
assert.Len(t, errs, 1) |
| 79 |
assert.Equal(t, helpers.URLEncodedValidation, errs[0].ValidationType) |
| 80 |
}) |
| 81 |
|
| 82 |
t.Run("Schema is Nil", func(t *testing.T) { |
| 83 |
res, errs := TransformURLEncodedToSchemaJSON("foo=bar", nil, nil) |
| 84 |
assert.Empty(t, errs) |
| 85 |
assert.Equal(t, "bar", res["foo"]) |
| 86 |
}) |
| 87 |
|
| 88 |
t.Run("Apply Encoding Rules & Reserved Characters", func(t *testing.T) { |
| 89 |
props := orderedmap.New[string, *base.SchemaProxy]() |
| 90 |
props.Set("jsonField", base.CreateSchemaProxy(&base.Schema{Type: []string{helpers.Object}})) |
| 91 |
props.Set("restricted", base.CreateSchemaProxy(&base.Schema{Type: []string{helpers.String}})) |
| 92 |
|
| 93 |
schema := &base.Schema{Properties: props} |
| 94 |
|
| 95 |
encodings := orderedmap.New[string, *v3.Encoding]() |
| 96 |
encodings.Set("jsonField", &v3.Encoding{ContentType: helpers.JSONContentType}) |
| 97 |
encodings.Set("restricted", &v3.Encoding{AllowReserved: false}) |
| 98 |
|
| 99 |
body := `jsonField={"id":1}&restricted=badvalue!` |
| 100 |
|
| 101 |
res, errs := TransformURLEncodedToSchemaJSON(body, schema, encodings) |
| 102 |
|
| 103 |
assert.IsType(t, map[string]any{}, res["jsonField"]) |
| 104 |
|
| 105 |
assert.Len(t, errs, 1) |
| 106 |
assert.Contains(t, errs[0].Message, "contains reserved characters") |
| 107 |
}) |
| 108 |
|
| 109 |
t.Run("Encoding Error (Invalid JSON content type)", func(t *testing.T) { |
| 110 |
props := orderedmap.New[string, *base.SchemaProxy]() |
| 111 |
props.Set("badJson", base.CreateSchemaProxy(&base.Schema{})) |
| 112 |
schema := &base.Schema{Properties: props} |
| 113 |
|
| 114 |
encodings := orderedmap.New[string, *v3.Encoding]() |
| 115 |
encodings.Set("badJson", &v3.Encoding{ContentType: helpers.JSONContentType}) |
| 116 |
|
| 117 |
res, errs := TransformURLEncodedToSchemaJSON(`badJson={invalid`, schema, encodings) |
| 118 |
assert.Len(t, errs, 1) |
| 119 |
|
| 120 |
assert.Equal(t, helpers.URLEncodedValidation, errs[0].ValidationType) |
| 121 |
|
| 122 |
assert.Equal(t, "{invalid", res["badJson"]) |
| 123 |
}) |
| 124 |
|
| 125 |
t.Run("Coercion triggered", func(t *testing.T) { |
| 126 |
props := orderedmap.New[string, *base.SchemaProxy]() |
| 127 |
props.Set("num", base.CreateSchemaProxy(&base.Schema{Type: []string{helpers.Integer}})) |
| 128 |
schema := &base.Schema{Properties: props, Type: []string{helpers.Object}} |
| 129 |
|
| 130 |
res, errs := TransformURLEncodedToSchemaJSON("num=123", schema, nil) |
| 131 |
assert.Empty(t, errs) |
| 132 |
assert.Equal(t, int64(123), res["num"]) |
| 133 |
}) |
| 134 |
} |
| 135 |
|
| 136 |
func TestApplyEncodingRules(t *testing.T) { |
| 137 |
boolPtr := func(b bool) *bool { return &b } |
| 138 |
|
| 139 |
t.Run("DeepObject Style", func(t *testing.T) { |
| 140 |
enc := &v3.Encoding{Style: "deepObject"} |
| 141 |
|
| 142 |
res, _ := applyEncodingRules("not-map", enc, nil) |
| 143 |
assert.Equal(t, "not-map", res) |
| 144 |
|
| 145 |
m := map[string]any{"k": "v"} |
| 146 |
res2, _ := applyEncodingRules(m, enc, nil) |
| 147 |
assert.Equal(t, m, res2) |
| 148 |
}) |
| 149 |
|
| 150 |
t.Run("Array Delimiters", func(t *testing.T) { |
| 151 |
schema := &base.Schema{Type: []string{helpers.Array}} |
| 152 |
|
| 153 |
encSpace := &v3.Encoding{Style: "spaceDelimited"} |
| 154 |
res, _ := applyEncodingRules("a b c", encSpace, schema) |
| 155 |
assert.Equal(t, []string{"a", "b", "c"}, res) |
| 156 |
|
| 157 |
encPipe := &v3.Encoding{Style: "pipeDelimited"} |
| 158 |
res, _ = applyEncodingRules("a|b|c", encPipe, schema) |
| 159 |
assert.Equal(t, []string{"a", "b", "c"}, res) |
| 160 |
|
| 161 |
encForm := &v3.Encoding{Style: "form", Explode: boolPtr(false)} |
| 162 |
res, _ = applyEncodingRules("a,b,c", encForm, schema) |
| 163 |
assert.Equal(t, []string{"a", "b", "c"}, res) |
| 164 |
}) |
| 165 |
} |
| 166 |
|
| 167 |
func TestValidateEncodingRecursive(t *testing.T) { |
| 168 |
var errs []*derrors.ValidationError |
| 169 |
|
| 170 |
validateEncodingRecursive("p", "val!", true, &errs, nil) |
| 171 |
assert.Empty(t, errs) |
| 172 |
|
| 173 |
validateEncodingRecursive("p", "val!", false, &errs, nil) |
| 174 |
assert.Len(t, errs, 1) |
| 175 |
|
| 176 |
errs = nil |
| 177 |
validateEncodingRecursive("arr", []any{"ok", "bad!"}, false, &errs, nil) |
| 178 |
assert.Len(t, errs, 1) |
| 179 |
|
| 180 |
errs = nil |
| 181 |
validateEncodingRecursive("map", map[string]any{"k": "bad!"}, false, &errs, nil) |
| 182 |
assert.Len(t, errs, 1) |
| 183 |
|
| 184 |
errs = nil |
| 185 |
validateEncodingRecursive("s_arr", []string{"ok", "bad!"}, false, &errs, nil) |
| 186 |
assert.Len(t, errs, 1) |
| 187 |
} |
| 188 |
|
| 189 |
func TestCoerceValue(t *testing.T) { |
| 190 |
schemaInt := &base.Schema{Type: []string{helpers.Integer}} |
| 191 |
schemaNum := &base.Schema{Type: []string{helpers.Number}} |
| 192 |
schemaBool := &base.Schema{Type: []string{helpers.Boolean}} |
| 193 |
schemaStr := &base.Schema{Type: []string{helpers.String}} |
| 194 |
|
| 195 |
t.Run("Complex Schema Aggregation (AllOf)", func(t *testing.T) { |
| 196 |
s := &base.Schema{ |
| 197 |
AllOf: []*base.SchemaProxy{ |
| 198 |
base.CreateSchemaProxy(schemaInt), |
| 199 |
}, |
| 200 |
} |
| 201 |
res := coerceValue("123", s) |
| 202 |
assert.Equal(t, int64(123), res) |
| 203 |
}) |
| 204 |
|
| 205 |
t.Run("No Target Types", func(t *testing.T) { |
| 206 |
res := coerceValue("val", &base.Schema{}) |
| 207 |
assert.Equal(t, "val", res) |
| 208 |
res = coerceValue("newVal", nil) |
| 209 |
assert.Equal(t, "newVal", res) |
| 210 |
}) |
| 211 |
|
| 212 |
t.Run("String Slice input (take first)", func(t *testing.T) { |
| 213 |
res := coerceValue([]string{"123"}, schemaInt) |
| 214 |
assert.Equal(t, int64(123), res) |
| 215 |
}) |
| 216 |
|
| 217 |
t.Run("Integer Conversions", func(t *testing.T) { |
| 218 |
assert.Equal(t, "abc", coerceValue("abc", schemaInt)) |
| 219 |
assert.Equal(t, "", coerceValue("", schemaInt)) |
| 220 |
assert.Equal(t, 123, coerceValue(123, schemaInt)) |
| 221 |
assert.Equal(t, int64(123), coerceValue("123", schemaInt)) |
| 222 |
}) |
| 223 |
|
| 224 |
t.Run("Number Conversions", func(t *testing.T) { |
| 225 |
assert.Equal(t, 12.34, coerceValue("12.34", schemaNum)) |
| 226 |
assert.Equal(t, "abc", coerceValue("abc", schemaNum)) |
| 227 |
assert.Equal(t, 13.2, coerceValue(13.2, schemaNum)) |
| 228 |
assert.Equal(t, 5, coerceValue(5, nil)) |
| 229 |
}) |
| 230 |
|
| 231 |
t.Run("Boolean Conversions", func(t *testing.T) { |
| 232 |
assert.Equal(t, true, coerceValue("true", schemaBool)) |
| 233 |
assert.Equal(t, 123, coerceValue(123, schemaBool)) |
| 234 |
}) |
| 235 |
|
| 236 |
t.Run("String Conversions", func(t *testing.T) { |
| 237 |
assert.Equal(t, "val", coerceValue("val", schemaStr)) |
| 238 |
assert.Equal(t, "123", coerceValue(123, schemaStr)) |
| 239 |
}) |
| 240 |
|
| 241 |
t.Run("Array Conversions", func(t *testing.T) { |
| 242 |
arrSchema := &base.Schema{ |
| 243 |
Type: []string{helpers.Array}, |
| 244 |
Items: &base.DynamicValue[*base.SchemaProxy, bool]{A: base.CreateSchemaProxy(&base.Schema{ |
| 245 |
Type: []string{helpers.Integer}, |
| 246 |
})}, |
| 247 |
} |
| 248 |
|
| 249 |
noItem := coerceValue("a", &base.Schema{ |
| 250 |
Type: []string{helpers.Array}, |
| 251 |
}) |
| 252 |
assert.Equal(t, []any{"a"}, noItem) |
| 253 |
|
| 254 |
res1 := coerceValue([]any{"1", "2"}, arrSchema) |
| 255 |
assert.Equal(t, []any{int64(1), int64(2)}, res1) |
| 256 |
|
| 257 |
res2 := coerceValue([]string{"1", "2"}, arrSchema) |
| 258 |
assert.Equal(t, []any{int64(1), int64(2)}, res2) |
| 259 |
|
| 260 |
mapInput := map[string]any{"1": "20", "0": "10"} |
| 261 |
res3 := coerceValue(mapInput, arrSchema) |
| 262 |
assert.IsType(t, []any{}, res3) |
| 263 |
sliceRes := res3.([]any) |
| 264 |
assert.Equal(t, int64(10), sliceRes[0]) |
| 265 |
assert.Equal(t, int64(20), sliceRes[1]) |
| 266 |
|
| 267 |
mapBad := map[string]any{"foo": "bar"} |
| 268 |
res4 := coerceValue(mapBad, arrSchema) |
| 269 |
assert.Equal(t, mapBad, res4) |
| 270 |
|
| 271 |
res5 := coerceValue("10", arrSchema) |
| 272 |
assert.Equal(t, []any{int64(10)}, res5) |
| 273 |
}) |
| 274 |
|
| 275 |
t.Run("Object Conversions", func(t *testing.T) { |
| 276 |
objSchema := &base.Schema{ |
| 277 |
Type: []string{helpers.Object}, |
| 278 |
Properties: orderedmap.New[string, *base.SchemaProxy](), |
| 279 |
} |
| 280 |
objSchema.Properties.Set("num", base.CreateSchemaProxy(schemaInt)) |
| 281 |
|
| 282 |
input := map[string]any{"num": "55", "other": "val"} |
| 283 |
|
| 284 |
res := coerceValue(input, objSchema) |
| 285 |
resMap, ok := res.(map[string]any) |
| 286 |
assert.True(t, ok) |
| 287 |
assert.Equal(t, int64(55), resMap["num"]) |
| 288 |
assert.Equal(t, "val", resMap["other"]) |
| 289 |
}) |
| 290 |
} |
| 291 |
|
| 292 |
func TestIsArraySchema(t *testing.T) { |
| 293 |
assert.False(t, isArraySchema(nil)) |
| 294 |
assert.False(t, isArraySchema(&base.Schema{Type: []string{"string"}})) |
| 295 |
assert.True(t, isArraySchema(&base.Schema{Type: []string{"array"}})) |
| 296 |
} |
| 297 |
|
| 298 |
func TestComplexBodies(t *testing.T) { |
| 299 |
spec := `{ |
| 300 |
"openapi": "3.1.0", |
| 301 |
"paths": { |
| 302 |
"/posts": { |
| 303 |
"put": { |
| 304 |
"requestBody": { |
| 305 |
"content": { |
| 306 |
"application/x-www-form-urlencoded": { |
| 307 |
"encoding": { |
| 308 |
"payload": { |
| 309 |
"contentType": "application/json" |
| 310 |
}, |
| 311 |
"title": { |
| 312 |
"allowReserved": true |
| 313 |
}, |
| 314 |
"pipeArr": { |
| 315 |
"style": "pipeDelimited" |
| 316 |
}, |
| 317 |
"spaceArr": { |
| 318 |
"style": "spaceDelimited" |
| 319 |
}, |
| 320 |
"unexplodedArr": { |
| 321 |
"explode": false |
| 322 |
} |
| 323 |
}, |
| 324 |
"schema": { |
| 325 |
"additionalProperties": false, |
| 326 |
"properties": { |
| 327 |
"content": { |
| 328 |
"type": "array", |
| 329 |
"items": { |
| 330 |
"type": "object", |
| 331 |
"additionalProperties": false, |
| 332 |
"properties": { |
| 333 |
"name": {"oneOf": [ |
| 334 |
{ |
| 335 |
"type": ["boolean"] |
| 336 |
}, |
| 337 |
{ |
| 338 |
"type": ["integer"] |
| 339 |
}]} |
| 340 |
} |
| 341 |
} |
| 342 |
}, |
| 343 |
"bool": { |
| 344 |
"type": ["boolean"], |
| 345 |
"enum": [false] |
| 346 |
}, |
| 347 |
"reserved": { |
| 348 |
"type": ["string"] |
| 349 |
}, |
| 350 |
"title": { |
| 351 |
"type": ["string"] |
| 352 |
}, |
| 353 |
"pipeArr": { |
| 354 |
"type": "array", |
| 355 |
"items": {"type": "integer"} |
| 356 |
}, |
| 357 |
"spaceArr": { |
| 358 |
"type": "array", |
| 359 |
"items": {"type": "integer"} |
| 360 |
}, |
| 361 |
"unexplodedArr": { |
| 362 |
"type": "array", |
| 363 |
"items": {"type": "integer"} |
| 364 |
}, |
| 365 |
"payload": { |
| 366 |
"type": "object", |
| 367 |
"additionalProperties": false, |
| 368 |
"properties": { |
| 369 |
"hey": { |
| 370 |
"type": "array", |
| 371 |
"items": { |
| 372 |
"type": "boolean" |
| 373 |
} |
| 374 |
} |
| 375 |
} |
| 376 |
} |
| 377 |
}, |
| 378 |
"required": ["title", "bool"], |
| 379 |
"type": "object" |
| 380 |
} |
| 381 |
} |
| 382 |
}, |
| 383 |
"required": true |
| 384 |
} |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
` |
| 390 |
|
| 391 |
doc, err := libopenapi.NewDocument([]byte(spec)) |
| 392 |
assert.NoError(t, err) |
| 393 |
|
| 394 |
v3Doc, err := doc.BuildV3Model() |
| 395 |
assert.NoError(t, err) |
| 396 |
|
| 397 |
contentSchema := v3Doc.Model.Paths.PathItems.GetOrZero("/posts").Put.RequestBody.Content.GetOrZero("application/x-www-form-urlencoded") |
| 398 |
schema := contentSchema.Schema.Schema() |
| 399 |
encoding := contentSchema.Encoding |
| 400 |
|
| 401 |
v := NewURLEncodedValidator() |
| 402 |
|
| 403 |
valid, errs := v.ValidateURLEncodedString(schema, encoding, "bool=false&title=test&content[0][name]=true") |
| 404 |
assert.True(t, valid) |
| 405 |
assert.Len(t, errs, 0) |
| 406 |
|
| 407 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, "bool=false&title=test&content[0][name]=4") |
| 408 |
assert.True(t, valid) |
| 409 |
assert.Len(t, errs, 0) |
| 410 |
|
| 411 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, "bool=false&title=test&content[0][name]=4.4") |
| 412 |
assert.False(t, valid) |
| 413 |
assert.Len(t, errs, 1) |
| 414 |
|
| 415 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, "bool=true&title=test&content[0][name]=true") |
| 416 |
assert.False(t, valid) |
| 417 |
assert.Len(t, errs, 1) |
| 418 |
|
| 419 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, "bool=false&content[0][name]=true") |
| 420 |
assert.False(t, valid) |
| 421 |
assert.Len(t, errs, 1) |
| 422 |
|
| 423 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, "bool=false&title") |
| 424 |
assert.True(t, valid) |
| 425 |
assert.Len(t, errs, 0) |
| 426 |
|
| 427 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&payload={"hey": [true, false]}`) |
| 428 |
assert.True(t, valid) |
| 429 |
assert.Len(t, errs, 0) |
| 430 |
|
| 431 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&payload={"hey": [2], "adittional": false}`) |
| 432 |
assert.False(t, valid) |
| 433 |
assert.Len(t, errs, 1) |
| 434 |
|
| 435 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title=do not use #`) |
| 436 |
assert.True(t, valid) |
| 437 |
assert.Len(t, errs, 0) |
| 438 |
|
| 439 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&reserved=do not use #`) |
| 440 |
assert.False(t, valid) |
| 441 |
assert.Len(t, errs, 1) |
| 442 |
|
| 443 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&pipeArr=1|2|3`) |
| 444 |
assert.True(t, valid) |
| 445 |
assert.Len(t, errs, 0) |
| 446 |
|
| 447 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&spaceArr=1 2 3`) |
| 448 |
assert.True(t, valid) |
| 449 |
assert.Len(t, errs, 0) |
| 450 |
|
| 451 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&spaceArr=1%202%203`) |
| 452 |
assert.True(t, valid) |
| 453 |
assert.Len(t, errs, 0) |
| 454 |
|
| 455 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, `bool=false&title&unexplodedArr=1,2,3`) |
| 456 |
assert.True(t, valid) |
| 457 |
assert.Len(t, errs, 0) |
| 458 |
} |
| 459 |
|
| 460 |
func TestValidateURLEncoded(t *testing.T) { |
| 461 |
spec := `openapi: 3.0.0 |
| 462 |
paths: |
| 463 |
/collection: |
| 464 |
get: |
| 465 |
responses: |
| 466 |
'200': |
| 467 |
content: |
| 468 |
application/x-www-form-urlencoded: |
| 469 |
schema: |
| 470 |
type: object` |
| 471 |
|
| 472 |
doc, err := libopenapi.NewDocument([]byte(spec)) |
| 473 |
assert.NoError(t, err) |
| 474 |
|
| 475 |
v3Doc, err := doc.BuildV3Model() |
| 476 |
assert.NoError(t, err) |
| 477 |
|
| 478 |
contentSchema := v3Doc.Model.Paths.PathItems.GetOrZero("/collection").Get.Responses.Codes.GetOrZero("200").Content.GetOrZero("application/x-www-form-urlencoded") |
| 479 |
schema := contentSchema.Schema.Schema() |
| 480 |
encoding := contentSchema.Encoding |
| 481 |
|
| 482 |
v := NewURLEncodedValidator() |
| 483 |
|
| 484 |
valid, errs := v.ValidateURLEncodedStringWithVersion(schema, encoding, "a=1", 3.1) |
| 485 |
assert.True(t, valid) |
| 486 |
assert.Empty(t, errs) |
| 487 |
|
| 488 |
valid, _ = v.ValidateURLEncodedStringWithVersion(nil, nil, "a=1", 3.1) |
| 489 |
assert.False(t, valid) |
| 490 |
|
| 491 |
valid, errs = v.ValidateURLEncodedString(schema, encoding, "a=1") |
| 492 |
assert.True(t, valid) |
| 493 |
assert.Empty(t, errs) |
| 494 |
|
| 495 |
valid, _ = v.ValidateURLEncodedString(nil, nil, "a=1") |
| 496 |
assert.False(t, valid) |
| 497 |
} |