Skip to content

Validation changes to allow parameters in animations#20992

Merged
Enriqe merged 5 commits intoampproject:masterfrom
Enriqe:validation-anim-params
Feb 28, 2019
Merged

Validation changes to allow parameters in animations#20992
Enriqe merged 5 commits intoampproject:masterfrom
Enriqe:validation-anim-params

Conversation

@Enriqe
Copy link
Copy Markdown
Contributor

@Enriqe Enriqe commented Feb 21, 2019

Part of #20260

Allow new parameters for animations inside amp-story:

  • Allows new attributes: scale-start, scale-end, translate-x, translate-y
  • Validates that values for these attributes are valid (scale-start/end values must be numbers, and translate-x/y values must be numbers and end with px).

@Enriqe Enriqe changed the title Validation anim params Validation changes to allow parameters in animations Feb 21, 2019
@Enriqe Enriqe self-assigned this Feb 21, 2019
@Enriqe Enriqe marked this pull request as ready for review February 21, 2019 20:05
attrs: { name: "grid-area" }
attrs: {
name: "scale-end"
value_regex: "^[0-9]*$"
Copy link
Copy Markdown
Contributor

@newmuis newmuis Feb 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may want to reconsider this regular expression (here and below); as it's written it will:

  • Allow empty string
  • Allow 0 (maybe that's ok, even though it's kind of weird)
  • Disallow decimals

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note also that the "^" and "$" are implied. This behavior varies between different languages and implementations (javascript it's not implied), so we normalize in the validator code. You can assume that value_regex is a full match and blacklisted_value_regex is a partial match (ie: in both cases, the least likely to match or most conservative).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@newmuis I revised the regex, let me know what you think.

@Gregable thanks for the explanation!

attrs: {
name: "scale-end"
value_regex: "^[0-9]*$"
value_properties: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible to have multiple value settings for an AttrSpec. It's an implicit oneof. That is, it can't be both value_regex and value_properties. Please see https://github.com/ampproject/amphtml/blob/master/validator/validator.proto#L105

@Enriqe
Copy link
Copy Markdown
Contributor Author

Enriqe commented Feb 26, 2019

PTAL

@Enriqe Enriqe force-pushed the validation-anim-params branch from 11674b5 to be8686d Compare February 26, 2019 15:58
| </amp-story-page>
| </amp-story>
| </body>
| </html> No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: new line (you can configure your software to add it automatically on save I think)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Yeah I have that enabled but I think whenever you pass the --update_tests in the validator it removes it.

/cc @Gregable as FYI

@Enriqe Enriqe merged commit 659cd6f into ampproject:master Feb 28, 2019
@Enriqe Enriqe deleted the validation-anim-params branch February 28, 2019 16:21
twifkak added a commit to twifkak/amphtml that referenced this pull request Mar 7, 2019
@twifkak twifkak mentioned this pull request Mar 7, 2019
twifkak added a commit that referenced this pull request Mar 7, 2019
* cl/235984006 Revision bump for #21124

* cl/236141405 Validating ssr class values and attributes for transformed AMP

* cl/236207670 Validating SSR layout should use the SSR CalculateLayout

* cl/236240396 Revision bump for #20967

* cl/236242005 Revision bump for #20992

* cl/236357124 Allow `meta name=amp-recaptcha-input`

* cl/236374806 Allow `meta name=amp-list-load-more`

* cl/236486003 Limit depth of recursion in CSS parsing.

* cl/236922121 n/a

* cl/236944297 allow i-amphtml-sizer for transformed amp-story

* eslint fixes
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* validation vfx params

* renaming

* revise regex and update examples

* don't allow half pixel values

* newlines
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* cl/235984006 Revision bump for ampproject#21124

* cl/236141405 Validating ssr class values and attributes for transformed AMP

* cl/236207670 Validating SSR layout should use the SSR CalculateLayout

* cl/236240396 Revision bump for ampproject#20967

* cl/236242005 Revision bump for ampproject#20992

* cl/236357124 Allow `meta name=amp-recaptcha-input`

* cl/236374806 Allow `meta name=amp-list-load-more`

* cl/236486003 Limit depth of recursion in CSS parsing.

* cl/236922121 n/a

* cl/236944297 allow i-amphtml-sizer for transformed amp-story

* eslint fixes
bramanudom pushed a commit to bramanudom/amphtml that referenced this pull request Mar 22, 2019
* validation vfx params

* renaming

* revise regex and update examples

* don't allow half pixel values

* newlines
bramanudom pushed a commit to bramanudom/amphtml that referenced this pull request Mar 22, 2019
* cl/235984006 Revision bump for ampproject#21124

* cl/236141405 Validating ssr class values and attributes for transformed AMP

* cl/236207670 Validating SSR layout should use the SSR CalculateLayout

* cl/236240396 Revision bump for ampproject#20967

* cl/236242005 Revision bump for ampproject#20992

* cl/236357124 Allow `meta name=amp-recaptcha-input`

* cl/236374806 Allow `meta name=amp-list-load-more`

* cl/236486003 Limit depth of recursion in CSS parsing.

* cl/236922121 n/a

* cl/236944297 allow i-amphtml-sizer for transformed amp-story

* eslint fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants