Validator: Class representing a Validator.

Description Details Public fields Methods Examples

Description

Validators are used to validate input fields in a ShinyForm. Validators are to be used with the validatedInput function. A single input field can have several validators.

Details

Package shinyreformss defines a set of commonly used pre-defined Validators. These include:

ValidatorMinLength(minLength):

Will fail if string is shorter than minLength.

ValidatorMaxLength(maxLength):

Will fail if string is longer than maxLength.

ValidatorNonEmpty():

Will fail if string is empty.

Public fields

test

Function returning a boolean value which will be used to validate input.

failMessage

Error message to display when validation fails.

Methods

Public methods


Method new()

Creates a Validator object.

Usage
Validator$new(test, failMessage)
Arguments
test

A function to test the input. Should take a single value as input and return a boolean.

failMessage

A fail message to be displayed.


Method check()

Performs a check on the input.

Usage
Validator$check(value)
Arguments
value

Input value to be tested.

Returns

TRUE if the check passes, FALSE if otherwise.


Method clone()

The objects of this class are cloneable with this method.

Usage
Validator$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

1
2
3
4
5
if(interactive()){
Validator(function(value) {
  ...
}, "Validation failed!")
}

shinyreforms documentation built on July 2, 2020, 1:33 a.m.