-
Notifications
You must be signed in to change notification settings - Fork 824
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW: Validate the Title on Group is not empty #10113
NEW: Validate the Title on Group is not empty #10113
Conversation
1ee61fc
to
264d7e6
Compare
Makes sense from my perspective, but I may not have all the history why it wasn't done in past. |
I don't know the history either. Seems sensible to me though. There's a semi-decent chance it'll break somewhere else if there's a My bigger concern though would be with projects, rather than modules, this they'd be might break on Possible change this from validation to onBeforeWrite instead? e.g. |
Yeah, I think I view it the same, more concerned about existing project code that works with the I guess we could keep the validation and check |
I can make the changes in validation or onBeforeWrite, did come across another bug where you can duplicate the group codes by creating a Group with a previous title. Might be an idea to consider addressing this in this pull request as well. MariaDB [ss4vanilla]> SELECT ID, Title, Code FROM |
Yes duplicate Title and/or Code are both bad, so catching those in validation would be helpful |
If we’re worried about this breaking things like public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create([
'Title'
]));
return $validator;
} Someone could then still create a group with no title programatically if they like. Admittedly that won’t stop someone creating a group with a whitespace-only title, but if someone really wants to create a group with a name “ ” then why stop them? 😛 |
Nice one @kinglozzer! If there's no field for code to manage via the CMS UI, should it act like |
9c30c41
to
bcaaf33
Compare
NEW: Use trim to validate Group title NEW: Stop duplicate and empty Group titles NEW: Do not allow group codes to be duplicated
bcaaf33
to
d211573
Compare
Changes made to validate Title (CMS) and handle duplicate group codes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me, thanks @textagroup.
@kinglozzer or @emteknetnz — can you give it another tick, too? Thanks!
Looks like this has caused some build failures 😞 not sure why the PR build passed https://github.com/silverstripe/silverstripe-framework/runs/4087515550 |
I guess it’s because we now have to make the |
Fix: #10136 |
You can currently create a new Group in the Security section of the CMS and leave the Title blank or fill it with only whitespace.
This pull requests adds some more validation on the Group DataObject as well as updating the GroupTest unit test.