Documentation ¶
Overview ¶
Package validators implements custom shared PocketBase validators.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare(valueToCompare string) validation.RuleFunc
Compare checks whether the validated value matches another string.
Example:
validation.Field(&form.PasswordConfirm, validation.By(validators.Compare(form.Password)))
func UploadedFileMimeType ¶
func UploadedFileMimeType(validTypes []string) validation.RuleFunc
UploadedFileMimeType checks whether the validated `rest.UploadedFile` mimetype is within the provided allowed mime types.
Example:
validMimeTypes := []string{"test/plain","image/jpeg"} validation.Field(&form.File, validation.By(validators.UploadedFileMimeType(validMimeTypes)))
func UploadedFileSize ¶
func UploadedFileSize(maxBytes int) validation.RuleFunc
UploadedFileSize checks whether the validated `rest.UploadedFile` size is no more than the provided maxBytes.
Example:
validation.Field(&form.File, validation.By(validators.UploadedFileSize(1000)))
Types ¶
type RecordDataValidator ¶
type RecordDataValidator struct {
// contains filtered or unexported fields
}
RecordDataValidator defines a model.Record data validator using the provided record constraints and schema.
func NewRecordDataValidator ¶
func NewRecordDataValidator( dao *daos.Dao, record *models.Record, uploadedFiles []*rest.UploadedFile, ) *RecordDataValidator
NewRecordDataValidator creates new models.Record data validator using the provided record constraints and schema.
Example:
validator := NewRecordDataValidator(app.Dao(), record, nil) err := validator.Validate(map[string]any{"test":123})
Click to show internal directories.
Click to hide internal directories.