---
schema_version: "1"
id: 1a41150d97abb2105197e7e37b1b035682a0705abaf11c17b8239a91c81c2480
title: Validating sObjects and Fields
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/langCon_apex_SObjects_field_validation.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SObjects_field_validation.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 399b951730f6f2a99887a1e5afb2edb9f6a549212fe43f592c4d5a0f53e7ba55
---
# Validating sObjects and Fields

When Apex code is parsed and validated, all sObject and field references are validated against actual object and field names, and a parse-time exception is thrown when an invalid name is used.

In addition, the Apex parser tracks the custom objects and fields that are used, both in the code's syntax as well as in embedded SOQL and SOSL statements. The platform prevents users from making the following types of modifications when those changes cause Apex code to become invalid:

- Changing a field or object name
- Converting from one data type to another
- Deleting a field or object
- Making certain organization-wide changes, such as record sharing, field history tracking, or record types