validator: Defines a validation function and an error message for an...

Description Usage Arguments Value See Also Examples

View source: R/validator.R

Description

Validators are typically passed to the formServerFactory function that creates a server-part handler of the edit dialog.

Usage

1
validator(inputIds, errorMessages, f)

Arguments

inputIds

a vector of input IDs for the validation function f to be bound on

errorMessages

a vector of error messages corresponding to the input IDs. This character vector is recycled as needed to match the length of inputIds

f

a validation function that expects a single input argument and returns TRUE if the given input is valid. Note that this function must handle correctly the NULL value as well as the NA value.

Value

A list of instances of the S3 class validator. The size of the resulting list equals to the number of input IDs in 'inputIds'.

See Also

filledValidator, formServerFactory

Examples

1
2
3
    validator('attr1',
              'attr1 must be odd',
              function(v) { !is.null(v) && !is.na(v) && v %% 2 != 0 })

beerda/crudtable documentation built on July 13, 2020, 2:16 p.m.