You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,15 +12,15 @@ Package validator implements value validations for structs and individual fields
11
12
12
13
It has the following **unique** features:
13
14
14
-
-Cross Field and Cross Struct validations by using validation tags or custom validators.
15
-
-Slice, Array and Map diving, which allows any or all levels of a multidimensional field to be validated.
16
-
-Ability to dive into both map keys and values for validation
17
-
-Handles type interface by determining it's underlying type prior to validation.
18
-
-Handles custom field types such as sql driver Valuer see [Valuer](https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29)
19
-
-Alias validation tags, which allows for mapping of several validations to a single tag for easier defining of validations on structs
20
-
-Extraction of custom defined Field Name e.g. can specify to extract the JSON name while validating and have it available in the resulting FieldError
21
-
-Customizable i18n aware error messages.
22
-
-Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/master/_examples/gin-upgrading-overriding)
15
+
- Cross Field and Cross Struct validations by using validation tags or custom validators.
16
+
- Slice, Array and Map diving, which allows any or all levels of a multidimensional field to be validated.
17
+
- Ability to dive into both map keys and values for validation
18
+
- Handles type interface by determining it's underlying type prior to validation.
19
+
- Handles custom field types such as sql driver Valuer see [Valuer](https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29)
20
+
- Alias validation tags, which allows for mapping of several validations to a single tag for easier defining of validations on structs
21
+
- Extraction of custom defined Field Name e.g. can specify to extract the JSON name while validating and have it available in the resulting FieldError
22
+
- Customizable i18n aware error messages.
23
+
- Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/master/_examples/gin-upgrading-overriding)
23
24
24
25
A Call for Maintainers
25
26
----------------------
@@ -31,11 +32,11 @@ Installation
31
32
32
33
Use go get.
33
34
34
-
go get github.com/go-playground/validator/v10
35
+
go get github.com/go-playground/validator/v10
35
36
36
37
Then import the validator package into your own code.
Validator returns only InvalidValidationError for bad validation input, nil or ValidationErrors as type error; so, in your code all you need to do is check if the error returned is not nil, and if it's not check if error is InvalidValidationError ( if necessary, most of the time it isn't ) type cast it to type ValidationErrors like so:
-[Custom Field Types](https://github.com/go-playground/validator/blob/master/_examples/custom/main.go)
@@ -71,13 +72,15 @@ Please see https://pkg.go.dev/github.com/go-playground/validator/v10 for detaile
71
72
Baked-in Validations
72
73
------
73
74
74
-
### Special Notes:
75
+
### Special Notes
76
+
75
77
- If new to using validator it is highly recommended to initialize it using the `WithRequiredStructEnabled` option which is opt-in to new behaviour that will become the default behaviour in v11+. See documentation for more details.
Here is a list of software that complements using this library either pre or post validation.
349
359
350
-
*[form](https://github.com/go-playground/form) - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.
351
-
*[mold](https://github.com/go-playground/mold) - A general library to help modify or set data within data structures and other objects
360
+
-[form](https://github.com/go-playground/form) - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.
361
+
-[mold](https://github.com/go-playground/mold) - A general library to help modify or set data within data structures and other objects
352
362
353
363
How to Contribute
354
364
------
@@ -360,20 +370,22 @@ Maintenance and support for SDK major versions
360
370
361
371
See prior discussion [here](https://github.com/go-playground/validator/discussions/1342) for more details.
362
372
363
-
This package is aligned with the [Go release policy](https://go.dev/doc/devel/release) in that support is guaranteed for
373
+
This package is aligned with the [Go release policy](https://go.dev/doc/devel/release) in that support is guaranteed for
364
374
the two most recent major versions.
365
375
366
-
This does not mean the package will not work with older versions of Go, only that we reserve the right to increase the
367
-
MSGV(Minimum Supported Go Version) when the need arises to address Security issues/patches, OS issues & support or newly
376
+
This does not mean the package will not work with older versions of Go, only that we reserve the right to increase the
377
+
MSGV(Minimum Supported Go Version) when the need arises to address Security issues/patches, OS issues & support or newly
368
378
introduced functionality that would greatly benefit the maintenance and/or usage of this package.
369
379
370
380
If and when the MSGV is increased it will be done so in a minimum of a `Minor` release bump.
371
381
372
382
License
373
383
-------
384
+
374
385
Distributed under MIT License, please see license file within the code for more details.
375
386
376
387
Maintainers
377
388
-----------
389
+
378
390
This project has grown large enough that more than one person is required to properly support the community.
379
-
If you are interested in becoming a maintainer please reach out to me https://github.com/deankarn
391
+
If you are interested in becoming a maintainer please reach out to me <https://github.com/deankarn>
// isOciTag is the validation function for validating if the current field's value is a valid OCI tag, as described in the OCI Distribution Specification: https://github.com/opencontainers/distribution-spec/blob/main/spec.md
0 commit comments