vext

package module
v0.0.0-...-1844d4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 3 Imported by: 2

README

vext

Extension validator factories for validating.

Installation

$ go get github.com/RussellLuo/vext@latest

Documentation

Check out the Godoc.

License

MIT

Documentation

Overview

Example (Email)
package main

import (
	"fmt"

	v "github.com/RussellLuo/validating/v3"
	"github.com/RussellLuo/vext"
)

func main() {
	value := "foo#example.com"
	if err := v.Validate(v.Value(value, vext.Email())); err != nil {
		fmt.Printf("err: %v\n", err)
	}

}
Output:

err: INVALID(invalid email)
Example (Ip)
package main

import (
	"fmt"

	v "github.com/RussellLuo/validating/v3"
	"github.com/RussellLuo/vext"
)

func main() {
	value := "127.0.0."
	if err := v.Validate(v.Value(value, vext.IP())); err != nil {
		fmt.Printf("err: %v\n", err)
	}

}
Output:

err: INVALID(invalid IP)
Example (Time)
package main

import (
	"fmt"
	"time"

	v "github.com/RussellLuo/validating/v3"
	"github.com/RussellLuo/vext"
)

func main() {
	value := "2006-01-02T15:04:05" // missing timezone
	if err := v.Validate(v.Value(value, vext.Time(time.RFC3339))); err != nil {
		fmt.Printf("err: %v\n", err)
	}

}
Output:

err: INVALID(invalid time)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Email

func Email() *v.MessageValidator

func IP

func IP() *v.MessageValidator

func Time

func Time(layout string) (mv *v.MessageValidator)

Time is a leaf validator factory used to create a validator, which will succeed when the field's value matches the given time format specified by layout.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL