Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Validator] AddYaml constraint for validating YAML content#53749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

symfonyaml
Copy link
Contributor

@symfonyamlsymfonyaml commentedFeb 3, 2024
edited by OskarStark
Loading

QA
Branch?7.2
Bug fix?no
New feature?yes
Deprecations?no
Ticket?no
LicenseMIT

Purpose

Inspired by theJson constraint, I've added a new feature to the Validator component for validating YAML content with a dedicated constraint.

Real world use case: Having configuration settings stored in YAML format within a database. With this new feature, you can validate the integrity of these configurations, ensuring the YAML syntax is OK.

Options

I've added aflags option to this constraint, aligning with theYaml parser flags.

Exemple

namespaceApp\Entity;useSymfony\Component\Validator\ConstraintsasAssert;useSymfony\Component\Yaml\Yaml;class Configuration{    #[Assert\Yaml(flags: Yaml::PARSE_DATETIME)]privatestring$content;}

smnandre, andreybolonin, adam-paterson, and abedcodes reacted with hooray emoji
Copy link
ContributorAuthor

@symfonyamlsymfonyaml left a comment

Choose a reason for hiding this comment

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

Resolved :)

@xabbuh
Copy link
Member

Can you please rebase your changes onto the latest7.1 branch? The failures mostly look related to issue we resolved recently.

symfonyaml reacted with thumbs up emoji

@symfonyaml
Copy link
ContributorAuthor

The followingPsalm issue looks like false positive to me 🤔 :

YamlValidator.php:43:95:UndefinedVariable: Cannot find referenced variable $prevErrorHandler

Thisbit of code is a copy of theLintCommand::validate() method.

@symfonyamlsymfonyamlforce-pushed thefeature-validator-yaml-constraint branch fromd549f65 to594682cCompareMarch 4, 2024 11:52
@symfonyamlsymfonyamlforce-pushed thefeature-validator-yaml-constraint branch from594682c to912607bCompareApril 12, 2024 08:16
Copy link
Member

@xabbuhxabbuh left a comment

Choose a reason for hiding this comment

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

with the suggested change

symfonyaml reacted with thumbs up emoji
@symfonyaml
Copy link
ContributorAuthor

symfonyaml commentedApr 19, 2024
edited
Loading

@xabbuh All done in commit5b95cfd , thanks

@OskarStarkOskarStark modified the milestones:7.1,nextApr 22, 2024
@xabbuhxabbuh added ❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze" and removed ❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze" labelsApr 23, 2024
@symfonyamlsymfonyamlforce-pushed thefeature-validator-yaml-constraint branch from2c88c44 toe26da28CompareMay 7, 2024 18:04
Comment on lines +44 to +46
if (\E_USER_DEPRECATED === $level) {
throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the purpose of this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@ro0NL Taken from the YamlLintCommand.php

Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

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

Rebase needed.

symfonyaml reacted with thumbs up emoji
@symfonyamlsymfonyamlforce-pushed thefeature-validator-yaml-constraint branch frome26da28 tobcbeb64CompareJune 13, 2024 17:03
@OskarStarkOskarStark changed the title[Validator] Add Yaml constraint for validating Yaml content[Validator] AddYaml constraint for validating YAML contentJun 14, 2024
@fabpotfabpotforce-pushed thefeature-validator-yaml-constraint branch from1e36e57 to023d48cCompareJune 14, 2024 08:17
@fabpot
Copy link
Member

Thank you@symfonyaml.

@fabpotfabpot merged commite0ad00c intosymfony:7.2Jun 14, 2024
7 of 10 checks passed
@symfonyamlsymfonyaml deleted the feature-validator-yaml-constraint branchOctober 21, 2024 14:44
@fabpotfabpot mentioned this pull requestOct 27, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@stofstofstof requested changes

@OskarStarkOskarStarkOskarStark left review comments

@ro0NLro0NLro0NL left review comments

@fabpotfabpotfabpot approved these changes

@derrabusderrabusderrabus approved these changes

@xabbuhxabbuhxabbuh approved these changes

@chalasrchalasrAwaiting requested review from chalasr

Assignees
No one assigned
Projects
None yet
Milestone
7.2
Development

Successfully merging this pull request may close these issues.

8 participants
@symfonyaml@xabbuh@fabpot@stof@OskarStark@ro0NL@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp