stringCase validator

Check if a string is a lower or upper case one

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
casedata-fv-string-case___caseStringCan be lower (the default value) or upper
messagedata-fv-string-case___messageStringThe error message
Using with ES6 module
// You might need to change the importing path
import stringCase from 'formvalidation/dist/es6/validators/stringCase';
const result = stringCase().validate({
value: ...,
options: {
'case': ...,
message: ...,
},
});
// result is an object of
// {
// valid: true or false,
// message: The error message
// }

Basic example

The following form asks user to enter a credit card holder in uppercase:
stringCase validator

ES6 Module Example

The following snippet shows how to use the stringCase validator with ES6 module:
// You might need to change the importing path
import stringCase from 'formvalidation/dist/es6/validators/stringCase';
const res1 = stringCase().validate({
value: 'JOHN SMITH',
options: {
case: 'upper',
message: 'The name must be in must be in uppercase',
},
});
// res1.valid === true
const res2 = stringCase().validate({
value: 'John Smith',
options: {
case: 'lower',
message: 'The name must be in must be in lowercase',
},
});
// res2.valid === false