Base64
Validate base64-encoded strings.
Validates that a value is valid base64-encoded data. The standard A-Za-z0-9+/= alphabet is expected.
| Config flag | Type | Description |
|---|
base64 | boolean | When true, requires the value to be valid base64. |
const form = useForm({
initialValues: { payload: '' },
validationSchema: {
payload: { base64: true },
},
});
import { V } from 'formify-js';
V.base64();
| Scenario | Message |
|---|
| Value is not valid base64 | Must be valid base64 |
| Value | Result |
|---|
'SGVsbG8gV29ybGQ=' | ✅ Valid |
'aGVsbG8=' | ✅ Valid |
'hello world' | ❌ Invalid (space not allowed) |
'aGVsbG8' | ❌ Invalid (bad padding) |
- Padding (
=) must be correct for the encoded length.
- This checks the character set and shape; it does not decode the payload.