Get desktop application:
View/edit binary Protocol Buffers messages
Specifies which AMP Layouts are supported by a given element. For the purpose of the validator, this specifies which values for layout, height, and width attributes are allowed. Also see https://github.com/ampproject/amphtml/blob/main/docs/spec/amp-html-layout.md TODO(johannes): Make the error messages around layouts better. This may require revamping the documentation for elements and/or the above spec, so that a user gets more clearly informed about which layouts are applicable to a given tag, what happens when layout attribute or other attributes are not set, etc. NEXT AVAILABLE TAG: 4
Used in:
Specifies which layouts are supported by this element.
Specifies whether this element has default dimensions. This corresponds to being allowlisted in naturalDimensions_ in https://github.com/ampproject/amphtml/blob/main/src/static-layout.js.
NEXT AVAILABLE TAG: 10
Used in:
An AncestorMarker is a state maintained on the stack of matching tags. When a TagSpec with an AncestorMarker matches, this Marker is placed on the stack until the matched html tag is popped from the stack. Other rules may be triggered by the presence of a specific AncestorMarker on the stack. NEXT AVAILABLE TAG: 2
Used in:
,NEXT AVAILABLE TAG: 2
Used in:
Set by <amp-sidebar> tags to allow autoscroll attributes on descendants. See https://github.com/ampproject/amphtml/pull/20524 for more context.
This spec is used by our CSS parser to determine what AT rules are allowed in the CSS spec. The term 'rule' here refers to the AT Rule in CSS, not a validation rule. NEXT AVAILABLE TAG: 4
Used in:
Name of the AT rule to parse. Do not include the '@' symbol (e.g. '@media' should be encoded as 'media'.
A MediaQuerySpec may only be set for an AtRuleSpec with the name "media". If not set, media queries will be left unparsed, so no errors or warnings about them will be reported.
Some tags share several attributes, so they're identified by unique key (see the attr_lists map in ValidatorRules). NEXT AVAILABLE TAG: 3
Used in:
Attributes that are not covered by at least one of these specs are disallowed. Within a given context (e.g., for a given TagSpec), names are unique. NEXT AVAILABLE TAG: 29
Used in:
,If provided, the Type Identifier(s) that either enable or disable this AttrSpec. If a Type Identifier is in enabled_by then this AttrSpec will be used in validating parsed documents with that Type Identifier. If a Type Identifier is in disabled_by then this AttrSpec will not be used in validating parsed documents with that Type Identifier. An AttrSpec can not have both enabled_by and disabled_by set.
Use lower-case attribute names only.
Within the context of the tag, *exactly one* of the attributes tagged with this identifier must be present. Per convention, this identifier should list the tags participating in the mandatory oneof: e.g. mandatory_oneof: "['foo', 'bar']"
Within the context of the tag, *at least one* of the attributes tagged with this identifier must be present. Per convention, this identifier should list the tags participating in the mandatory oneof: e.g. mandatory_oneof: "['foo', 'bar']"
The attribute value must be equal to the value in this field.
case sensitive
case insensitive
case sensitive
case insensitive
validates against a list of properties (see PropertySpec).
If set, the attribute value will be evaluated using the matching document level CSS rules. This flag is used for `style` attributes. If `value_doc_css` is set, only non-SVG css is applied. If `value_doc_css_svg` is set, SVG-specific CSS rules are also allowed for this attribute value.
} end oneof
If set, then the attribute value may not match this regex, which is always applied case-insensitively and as a partial match.
If set, generates a DEPRECATED_ATTR error with severity WARNING. The value of the deprecation field indicates what to use instead, e.g. the name of an attribute or tag.
If provided, a URL which links to the AMP HTML spec for this deprecation.
Valid CSS declarations.
If set true, the TagSpec containing this AttrSpec will be evaluated first for any encountered tag which matches the tag name and this attribute spec. May only be set for an AttrSpec where mandatory=true and type matches those specified in the comments of DispatchKeyType above.
If set to true, the TagSpec containing this AttrSpec implicitly has this attribute and the attribute is considered valid.
If set, this attr is considered part of an amp extended component, and requires that the named extended component script tag is present on the page.
If set, this attr is invalid unless the current tag has an ancestor tag which set one or more of the required markers.
Used in:
Indicates that the attribute does not form a dispatch key.
Indicates that the name of the attribute alone forms a dispatch key.
Indicates that the name + value of the attribute forms a dispatch key.
Indicates that the name + value + mandatory parent forms a dispatch key.
These two fields specify that values from one AttrSpec refer to values from another AttrSpec elsewhere on the page; validator will verify the references are not "dangling". These references may appear before or after their referents. For example, in the "id" AttrSpec in the "template" TagSpec, we have: add_value_to_set: TEMPLATE_IDS and in any "template" AttrSpec, we have: value_oneof_set: TEMPLATE_IDS NEXT AVAILABLE TAG: 3
Used in:
,Never used
<template id> values
<script id> values, referenced by <amp-script>
Used for validating attributes that require another attribute for some given set of conditions. E.g. attr name: "on" if_value_regex: "tap:.*" also_require_attr: "role" NEXT AVAILABLE TAG: 3
Used in:
If set, attribute's value must match to also require attribute(s). If not set, attribute automatically also require attribute(s).
case sensitive
If set, other attributes - identified by their name string - must be present as well.
NEXT AVAILABLE TAG: 12
Used in:
If set, the cdata contents cannot be greater than this length, in bytes. A value of -2 (default) indicates that there is no limit (unlimited). A value of -1 will always cause validation failure on match. -1 is used to implement the `amp-custom-length-check` attribute: (https://github.com/ampproject/amphtml/issues/22315#issuecomment-496681165)
If provided, a URL which linking to a section / sentence in the AMP HTML spec.
If non-empty, the text between the start / end tag must match this value.
If non-empty, the text between the start / end tag must match this regex.
If at least one CssSpec is provided, this cdata field will be parsed as CSS3, and any parsing errors will become validation errors.
If set to true, then only whitespace may be in the cdata contents. This is useful for script tags that reference extensions etc.
} end oneof
If any of these regexes match, then this cdata spec does not validate.
If true, the contents of this tag's CDATA text will be counted against the document level DocCssSpec CSS lengths.
TagSpec::child_tags uses this configuration to specify which child tags are expected for a specific tag. Matching child tags is done by tag name, while the parent is matched by TagSpec. The reason for this is that matching by tag spec name would produce less useful error messages, because we want to be able to produce a good message even if the tag spec name could not be determined because the enclosed child tag is invalid (no TagSpec matches). By doing a tag name match, we can produce a reasonable error regardless if a child tag was misplaced. NEXT AVAILABLE TAG: 5
Used in:
Unless set to -1 (the default), the parent tag must have exactly |mandatory_num_child_tags| immediate child tags.
If at least one tag name is specified, then the first child of the parent tag must have one of the provided names.
If at least one tag name is specified, then the child tags of the parent tag must have one of the provided tag names.
Unless set to -1 (the default), the parent tag must have a minimum of |mandatory_min_num_child_tags| immediate child tags.
NEXT AVAILABLE TAG: 4
Used in:
, ,The name of the declaration (e.g. display). Use lower-case attribute names only.
This would be a oneof, but this file only uses features in protobuf 2.5.0. begin oneof { The valid values of the declaration (e.g. block).
} end oneof
NEXT AVAILABLE TAG: 10
Used in:
Spec for how to parse CSS AT rules, one per AT rule. Must not contain duplicate names, and must contain at least one entry for the default.
Enables checks specific to the draft A4A specification. TODO(powdercloud): Make this more generic.
Enables checks specific to the style[keyframes] specification. TODO(chenshay): Make this more generic.
Any declaration listed here are allowed.
If false, declarations tagged with `!important` are considered errors. Most AMP stylesheets disallow `!important` to reserve this override for AMP's own styles.
Some style blocks share long lists of declarations, so they're identified by unique key. NEXT AVAILABLE TAG: 3
Used in:
A list of allowed tags for descendants of any level (children, grandchildren, great-grandchildren, etc). NEXT AVAILABLE TAG: 3
Used in:
Regex which, if matches the cdata of a tag, causes the tag validation to fail. NEXT AVAILABLE TAG: 3
Used in:
Syntax is partial match, use ^ and $ if you want global match.
Exactly one DocCssSpec will match each AMP document. This spec defines the default css rules for style attributes and publisher style tags across the entire document. Rules for specific tags may be overridden by those tags. NEXT AVAILABLE TAG: 20
Used in:
The html_format field tells the validator for which html formats (ie: (<html ⚡> vs <html a4⚡>) this DocCssSpec is defined for.
If a Type Identifier is in enabled_by then this DocCssSpec will be used in validating parsed documents with that Type Identifier. If a Type Identifier is in disabled_by then this DocCssSpec will not be used in validating parsed documents;: with that Type Identifier. An DocCssSpec can not have both enabled_by and disabled_by set.
If provided, a URL linking to a section / sentence in the AMP HTML spec.
Due to a bug, we allowed unlimited doc-level and per-inline-style bytes for CSS in non-AMP formats. To avoid breaking pages, some formats will only emit a warning for exceeding `max_bytes` and `max_bytes_per_inline_style`.
If set, the combined style amp-custom cdata contents and all inline style contents cannot be greater than this length, in bytes. A value of -2 (default) indicates that there is no limit (unlimited). A value of -1 will always cause validation failure.
If set, the inline style content (per use) cannot be greater than this length, in bytes.
If false, bytes inside URLs are not included in the byte calculation for `max_bytes`. This is used for handling signed exchange transformations which can potentially take the number of bytes over the 75,000 byte limit due to rewriting URLs to point at an AMP Cache.
If provided, a URL linking to a section / sentence in the AMP HTML spec.
If true, all declarations are allowed in style tags and inline style attributes, regardless of the contents of the `declaration` list.
If true, all variants of declarations that are vendor prefixes are allowed. for example, if `gradient` is an allowed declaration and this is true, then `-webkit-gradient` is also an allowed declaration.
Any declaration listed here is allowed in custom style tags and style attributes in any tag.
In addition to those listed in 'declaration', any declaration listed here is allowed in style attributes for SVG elements.
Top level lists of shared declarations, identified by unique key.
Top level lists of shared declarations, identified by unique key.
URLs found within CSS are checked against this spec.
If false, declarations tagged with `!important` are considered errors. Most AMP stylesheets disallow `!important` to reserve this override for AMP's own styles.
Exactly one DocSpec will match each AMP document. This spec defines some default rules for the entire document scoped by it's HtmlFormat and any Type Identifiers. NEXT AVAILABLE TAG: 6
Used in:
The html_format field tells the validator for which html formats (ie: (<html ⚡> vs <html a4⚡>) this DocSpec is defined for.
If a Type Identifier is in enabled_by then this DocSpec will be used in validating parsed documents with that Type Identifier. If a Type Identifier is in disabled_by then this DocSpec will not be used in validating parsed documents with that Type Identifier. An DocSpec can not have both enabled_by and disabled_by set.
If set, the entire document's content cannot be greater than this length, in bytes. A value of -2 (default) indicates that there is no limit (unlimited).
If provided, a URL linking to a section / sentence in the AMP HTML spec.
This feature was removed in October 2019, however there are still some callers that expect an ErrorCategory to be set. Do not rely on this in new code. TODO(#25188): Remove ErrorCategory completely.
(message has no fields)
Used in:
NEXT AVAILABLE TAG: 3
Used in:
Used in the verbose validator to select between multiple generated error types for a failing error. A higher number means that the error is more specific, ie: more helpful, preferred. NEXT AVAILABLE TAG: 3
Used in:
Specs specific to AMP Extensions. This is a field within TagSpec that replaces the standard tagspec list of attributes, requirements, etc. NEXT AVAILABLE TAG: 11
Used in:
e.g. "amp-video". This is used both as the attribute value for the 'custom-element' attribute value as well as part of the 'src' attribute value.
e.g. "0.1", "1.0", "latest".
If multiple TagSpecs for the same extension exist, separated by version, specify a version_name string to disambiguate their spec_names. For example, "v1.0" or "v0.1-0.2". This string will become part of the name used for referring to this extension in validator error messages.
deprecated_version must be a strict subset of version. If the version matches a deprecated_version, validation will emit a warning.
Bento supported versions (e.g. "1.0").
For older tags, we did not originally require that the tag only be included once, so those tags are exempted from the multiple inclusion ban.
Most extensions are custom-elements. For custom-template extensions, this value needs to be set true. E.g: amp-mustache. NEXT AVAILABLE TAG: 4
Used in:
TagSpec.requires_extension will be set to the new extension's name on one or more TagSpecs that require that extension. This typically creates 2 validation requirements: 1) If a tag is on the page whose TagSpec has the requires_extension field set, but that extension is not present, this is an error. (Usage requires extension). 2) If an extension is on the page, but no tags indicating usage of that extension via the required_extension field are on the page, this is an error. (Extension requires usage). The second requirement (extension requires usage) has a few exceptions: 1) For older extensions, implemented before these tagspec rules, we do not want to introduce a breaking change, so we exempt these extensions from the usage requirement. New extensions must use ERROR. 2) Some extensions, such as `amp-dynamic-css-classes`, do not have any associated tag in the document indicating usage. These extensions do not trigger warnings or errors. NEXT AVAILABLE TAG: 4
Used in:
Exception for exempted extensions. #1 above.
Exception for extensions with no usage-indicating tag. #2 above.
The HtmlFormat is the declared format in the top-level html tag, which prescribes a particular set of validation rules. This should be kept in sync with Request.HtmlFormat in github.com/ampproject/amppackager/transformer/request/request.proto.
(message has no fields)
NEXT AVAILABLE TAG: 6
Used in:
, ,Never used
Currently unused
This spec is used when parsing a media query inside a CSS @media rule. NEXT AVAILABLE TAG: 5
Used in:
If issues_as_error is true, then parsing errors and invalid types / features will be treated as validator errors, otherwise warnings.
These are the media query types and features allowed within the stylesheet. http://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#Syntax
Used for validating properties in attribute values. Our validator (via parse-viewport.h) implements the parsing algorithm as described here: https://drafts.csswg.org/css-device-adapt/#parsing-algorithm NEXT AVAILABLE TAG: 5
Used in:
Must be lowercase, and will be matched case-insensitively.
Must be lowercase, and will be matched case-insensitively.
} end oneof
NEXT AVAILABLE TAG: 2
Used in:
TagSpecs and reference points. Any TagSpec may define a list of reference points via the TagSpec::reference_points field. These reference points specify how DOM elements that are children of this parent tag fulfill particular functionality. For instance, a widget (implemented as an AMP tag) may require a login reference point. Any valid AMP tag would be allowed, whether it's a clickable DIV or an AMP-IMG or a BUTTON, so long as it *also* conforms to the reference point specification. This specification is a TagSpec which does not define a name (the name is set to the special value '$REFERENCE_POINT'), but rather identifies the reference point with AttrSpec requirements. For instance, the login reference point may require that there be a login attribute, or some end-point attribute with a URL, or similar. Therefore, for any child tags of a tag that defines reference points, they are first matched against these reference points, and only then are they validated as regular tags against the TagSpecs that are not reference points while their reference point attributes are skipped. The complexity of this mechanism is unfortunate but reduces the markup required and makes CSS styling more convenient. Please see the amp-live-list specification for an example. NEXT AVAILABLE TAG: 4
Used in:
A tag spec identified by its TagSpec::spec_name which specifies how a specific functionality for the parent tag is assigned.
At least one of the child tags of the parent defining this reference point must match it.
At most one of the child tags of the parent defining this reference point must match it.
This spec is used when parsing a CSS selector group as the prelude of a CSS qualified rule. For example "div.foo span.bar". If no SelectorSpec is provided, the selector groups are unconstrained. NEXT AVAILABLE TAG: 4
For each SelectorSpec list provided a single list element value of "*" indicates that any value is allowed (ie: that feature is unconstrained). An empty list indicates that no value is allowed (ie: that feature is disallowed). Otherwise, the list values are the only allowed values.
Used in:
Allowed attribute selector names. For example `foo` in the selector `.a[foo=bar]`.
Allowed pseudo class names. For example `checked` in `.a:checked`.
Allowed pseudo element names. For example `before` in `.a::before`.
Tags that are not covered by at least one of these specs are disallowed. Some tags are mandatory. Note that the tag name is not unique, that is, there can be multiple tag specs covering the same name, e.g., for multiple meta tags (with different attributes). NEXT AVAILABLE TAG: 40
Used in:
The html_format field tells the validator for which html formats (ie: (<html ⚡> vs <html a4⚡>) this HTML TagSpec is allowed to validate. The repeated field is not allowed to be empty, it must have at least one HtmlFormat.
If provided, the Type Identifier(s) that either enable or disable this TagSpec. If a Type Identifier is in `enabled_by` then this TagSpec will be used in validating parsed documents which include that Type Identifier. If a Type Identifier is in `disabled_by` then this TagSpec will not be used in validating parsed documents which include that Type Identifier. A TagSpec can not have both `enabled_by` and `disabled_by` set.
Use UPPER-CASE tag names only. If adding the same tag twice, then they must also have a spec_name string which is unique throughout all detail. Note: "$REFERENCE_POINT" is a special tag_name value. Reference points are partial tag specs which don't have a defined tag_name.
If provided, the spec_name must be unique within the validator rules. This string forms a a unique id for this TagSpec. If not set, the tag_name field is used as the unique id. This string is not used in error messages, see descriptive_name for that.
If `tag_name` is not a sufficient descriptor for error messages having to do with this tag spec, provide a `descriptive_name` value, which if present will be used in place of `tag_name`. Typically `descriptive_name` should include the tag_name in it, and should avoid using < and > in case downstream libraries of the validator fail to properly HTML escape rendered error strings.
If provided, this is a SCRIPT tag defining an amp custom element extension. The other fields, such as expected attributes, will be validated by the extension spec rules.
If set, this tag is considered part of an amp extended component, and requires that the named extended component script tag is present on the page.
If true, a tag conforming to this tag spec must occur at least once within the document.
A string identifying that this tag belongs to a set of alternative choices from which at least one needs to be satisfied.
If true, a tag conforming to this tag spec may occur at most once within the document.
If true, a tag conforming to this tag spec should occur at most once within the document. That is, unlike for unique, we'll emit a warning.
If set to "$ROOT", this tag must be the root tag. If set to any other string, the tag must be the direct child of the specified mandatory parent tag.
If set, the tag must descend from (not necessarily direct parent of) the specified mandatory parent string which is either a tag name or a tag spec_name (e.g. tag.name = "!DOCTYPE" or tag.spec_name = "html doctype").
Use only for tags where mandatory_ancestor is set. If tag validation fails due to the mandatory_ancestor, and this field is set, then the error detail will suggest the tag specified here as an alternative to consider.
This tag may not descend from any tag with any of these tag names or tag spec_names (e.g. tag.name = "!DOCTYPE" or tag.spec_name = "html doctype").
If set, all of the tag's descendants must be tags from the named list. A tag not in the named list will generate an error.
If set, other tags - identified by their detail string - must be present as well or a warning will be issued (will not invalidate doc).
Expresses a generic condition which is satisfied if this tag is found. Used in combination with the `requires` attribute on a different tag.
Expresses a generic condition which must be satisfied if this tag is found. Used in combination with the `satisfies` attributes on a different tag.
The excludes field is a generic condition, which must not be satisfied if this tag is found. Otherwise a TAG_EXCLUDED_BY_TAG error will be generated. Used in combination with the `satisfies` attributes on a different tag.
If set, generates a DEPRECATED_TAG error with severity WARNING. The value of the deprecation field indicates what to use instead, e.g. the name of a tag.
If provided, a URL which links to the AMP HTML spec for this deprecation.
This TagSpec will only validate against attributes explicitly listed within the TagSpec (attrs and attr_lists). No attributes from $GLOBAL_ATTRS and $AMP_LAYOUT_ATTRS are valid unless explicitly added as an attribute within the TagSpec. The field `amp_layout` is not allowed to be set when `explicit_attrs_only` is true.
Attribute specifications related to this tag.
Top level attr lists of shared tags, identified by unique key (see attr_lists map in ValidatorRules).
Note that these are evaluated after a particular TagSpec has been evaluated. Unlike other checks in this TagSpec, we no longer have the ability to fall back on a different TagSpec.
Specifies which tags can be the child tags, that is, immediately children of this tag in the document.
If set to true, this tag cannot have any siblings.
If set to true, this tag must be the last child of its parent.
The reference_points defined by this TagSpec instance determine how specific child tags are identified. Please see the comment for the ReferencePoint message.
If provided, a URL which linking to a section / sentence in the AMP HTML spec. If a TagSpec contains a requires_extension field, spec_url will be inherited from the named extension, unless overridden by the setting it here.
If set, specifies which AMP Layouts are supported by this element.
If set, triggers related validation rules for descendants of this tag.
NamedId's are used to uniquely identify specific TagSpecs in the validator rules in a stable manner. Most TagSpecs have no set NamedId. If a TagSpec has a NamedId it must be unique. In other words, no two TagSpec's may have the same NamedId except for the NOT_SET (0) value. NEXT AVAILABLE TAG: 3
Used in:
By convention, the first "word" in the Id should be the tag_name.
Used for validating urls in attribute values (such as href/src/srcset). NEXT AVAILABLE TAG: 5
Used in:
,protocol must be in lowercase (e.g. "javascript" not "JavaScript").
Whether the empty string '' is allowed for this URL value.
We record validation errors in a structured form, so that they can be worked with in code - e.g., to provide translated messages. In the Javascript implementation (validator.js), you may find the amp.validator.renderErrorMessage function which will make a human-readable string from the structured form. It should be easy to port this to other languages as needed; for instance Google has implementations in C++, Java, and for templates used in some frontends. NEXT AVAILABLE TAG: 10
Used in:
,This field is deprecated. Do not use.
Used only in JavaScript, if an error is emitted for a specific HTML tag and if that HTML tag has an attribute named data-amp-report-test, this string will be set and contain the value found for that attribute. This is used in tests to match specific errors to specific tags in the test cases. It is not a rendered value.
NEXT AVAILABLE TAG: 124
Used in:
, ,TODO(gregable): Fix this spelling error: 'precede'
The following codes are currently used only by A4A CSS validation.
NEXT AVAILABLE TAG: 5
Used in:
A document with at least one error of this severity fails validation.
A document may have warnings and still pass validation.
DO NOT REASSIGN the previously used values 2, 3.
The validation result provided by Validator instances (see Validator::Result in validator.h). To render such a proto see RenderValidationResult. NEXT AVAILABLE TAG: 9
The following field is deprecated and can return any value. Do not depend on this.
If the AMP document is a transformed AMP document, then this is the version of the transformers that were used to transform it. If the document is not transformed, then the transformer_version's value will be 0. Note: the AMP Pacakager's transformer library specifies the version as int64. However, JavaScript does not natively support int64 so int32 is used instead. https://github.com/ampproject/amppackager/blob/master/transformer/transformers/context.go
The type idenfitier of the parsed document, e.g. AMP, AMP4ADS or some other type that has yet to be defined. These are declared on the HTML tag and parsed by the Validator Engine.
The set of provisions from all matching AttrSpecs in this TagSpec match. If the TagSpec is selected, these will be added to the final set of provisions.
The set of requirements from all matching AttrSpecs in this TagSpec match. If the TagSpec is selected, these will be added to the final set of requirements.
NEXT AVAILABLE TAG: 3
Used in:
Top level message - start reading here. The validator knows about a set of tag specifications. NEXT AVAILABLE TAG: 22
The min file revision for validator.cc which can digest this file.
See comment in validator.protoascii.
Spec URL for information about mustache templates.
Spec URL for information about styles and amp-custom stylesheet
Spec URL for information about script tags.
The DocSpec rules are scoped by the document's HtmlFormat and Type Identifiers and defined within each DocSpec.
A value to be added to a particular ValueSet, as found when scanning the document (i.e. AttrSpec.add_value_to_set). NEXT AVAILABLE TAG: 3
Used in:
,The collection to add the attribute value to.
The value of the attribute itself.
A requirement that a particular value appears in a particular ValueSet (i.e. AttrSpec.value_oneof_set). All the provisions and requirements are collected until the document has been fully scanned, and then compared to ensure that all requirements are met. This allows provisions to appear after (or even alongside) requirements. NEXT AVAILABLE TAG: 3
Used in:
The provision that is required.
The error that will appear if the requirement is not met. This includes the line/col of the attribute that makes the requirement.