Formify Docs

Base64

Validate base64-encoded strings.

Base64

Validates that a value is valid base64-encoded data. The standard A-Za-z0-9+/= alphabet is expected.

Configuration

Config flagTypeDescription
base64booleanWhen true, requires the value to be valid base64.

With useForm

const form = useForm({
  initialValues: { payload: '' },
  validationSchema: {
    payload: { base64: true },
  },
});

With the V builder

import { V } from 'formify-js';

V.base64();

Default message

ScenarioMessage
Value is not valid base64Must be valid base64

Examples

ValueResult
'SGVsbG8gV29ybGQ='✅ Valid
'aGVsbG8='✅ Valid
'hello world'❌ Invalid (space not allowed)
'aGVsbG8'❌ Invalid (bad padding)

Notes

  • Padding (=) must be correct for the encoded length.
  • This checks the character set and shape; it does not decode the payload.

On this page