1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-28 18:11:17 +02:00
pocketbase/forms/validators/string.go
2022-07-07 00:19:05 +03:00

22 lines
511 B
Go

package validators
import (
validation "github.com/go-ozzo/ozzo-validation/v4"
)
// Compare checks whether the validated value matches another string.
//
// Example:
// validation.Field(&form.PasswordConfirm, validation.By(validators.Compare(form.Password)))
func Compare(valueToCompare string) validation.RuleFunc {
return func(value any) error {
v, _ := value.(string)
if v != valueToCompare {
return validation.NewError("validation_values_mismatch", "Values don't match.")
}
return nil
}
}