If the message text appears to be valid, the method returns non-zero.
If the message text is empty, contains invalid characters, or appears to
contain non-text data, the method returns zero. To get extended error
information, call GetLastError.
The ValidateText method is intended to help applications
detect invalid or malformed input before sending a request to a model.
It checks for common problems such as empty strings, text that consists
only of spaces or line breaks, illegal Unicode code points, non-printable
characters, and input that appears to contain binary data. The message
text cannot contain embedded null characters.
Applications that accept messages from users or other external
sources should validate the text before submitting it to a model. This can
help detect malformed or invalid input before a request is sent, reducing
the chance of unexpected results or incurring unnecessary usage costs.
This method does not evaluate the quality, safety, or semantic
meaning of the message. Although this method is most commonly used
to check prompts sent to a model, it can be used to validate any type
of text to ensure it is not malformed and contains printable
characters.
If your project uses the Unicode character set, this method
validates the text as UTF-16 Unicode. If your project uses the
Multi-Byte character set, it attempts to interpret the input as
UTF-8 encoded text. If the input is not valid UTF-8, it attempts
to convert the text to Unicode using the active code page and
the resulting Unicode text is validated.