stringCase validator
Check if a string is a lower or upper case one
Options
Using with form field
| Name | HTML attribute | Type | Description | 
|---|
case | data-fv-string-case___case | String | Can be lower (the default value) or upper | 
message | data-fv-string-case___message | String | The error message | 
Using the ES6 module
import { stringCase } from '/vendors/@form-validation/cjs/validator-string-case';
const result = stringCase().validate({
    value: ...,
    options: {
        'case': ...,
        message: ...,
    },
});
Using the npm package
- Install the validator package:
 
$ npm install @form-validation/validator-string-case
- Use the 
stringCase validator: 
import { stringCase } from '@form-validation/validator-string-case';
const result = stringCase().validate({
    value: ...,
    options: {
        'case': ...,
        message: ...,
    },
});
Basic example
The following form asks user to enter a credit card holder in uppercase:
NPM package example
The following snippet shows how to use the stringCase validator with the npm package:
import { stringCase } from '@form-validation/validator-string-case';
const res1 = stringCase().validate({
    value: 'JOHN SMITH',
    options: {
        case: 'upper',
        message: 'The name must be in must be in uppercase',
    },
});
const res2 = stringCase().validate({
    value: 'John Smith',
    options: {
        case: 'lower',
        message: 'The name must be in must be in lowercase',
    },
});
Changelog
- The validator doesn't work properly if the 
message property isn't defined