Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
field_validation
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
field_validation
Commits
502491aa
Commit
502491aa
authored
Aug 17, 2023
by
howard ge
Committed by
howard ge
Aug 17, 2023
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3381352
by g089h515r806: Add support for Symfony Uuid Constraint
parent
a67f4561
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/schema/field_validation.schema.yml
+11
-0
11 additions, 0 deletions
config/schema/field_validation.schema.yml
src/Plugin/FieldValidationRule/UuidConstraintFieldValidationRule.php
+71
-0
71 additions, 0 deletions
...FieldValidationRule/UuidConstraintFieldValidationRule.php
with
82 additions
and
0 deletions
config/schema/field_validation.schema.yml
+
11
−
0
View file @
502491aa
...
...
@@ -215,3 +215,14 @@ field_validation.rule.not_blank_constraint_rule:
message
:
type
:
string
label
:
'
Message'
field_validation.rule.uuid_constraint_rule
:
type
:
mapping
label
:
'
Uuid
constraint
validation
rule'
mapping
:
validate_mode
:
type
:
string
label
:
'
Validate
mode'
message
:
type
:
string
label
:
'
Message'
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Plugin/FieldValidationRule/UuidConstraintFieldValidationRule.php
0 → 100644
+
71
−
0
View file @
502491aa
<?php
namespace
Drupal\field_validation\Plugin\FieldValidationRule
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\field_validation
\ConstraintFieldValidationRuleBase
;
use
Drupal\field_validation
\FieldValidationRuleSetInterface
;
/**
* Provides funcationality for UuidConstraintFieldValidationRule.
*
* @FieldValidationRule(
* id = "uuid_constraint_rule",
* label = @Translation("Uuid constraint"),
* description = @Translation("Uuid constraint.")
* )
*/
class
UuidConstraintFieldValidationRule
extends
ConstraintFieldValidationRuleBase
{
/**
* {@inheritdoc}
*/
public
function
getConstraintName
():
string
{
return
"Uuid"
;
}
/**
* {@inheritdoc}
*/
public
function
isPropertyConstraint
():
bool
{
return
TRUE
;
}
/**
* {@inheritdoc}
*/
public
function
defaultConfiguration
()
{
return
[
'message'
=>
NULL
,
]
+
parent
::
defaultConfiguration
();
}
/**
* {@inheritdoc}
*/
public
function
buildConfigurationForm
(
array
$form
,
FormStateInterface
$form_state
)
{
$form
=
parent
::
buildConfigurationForm
(
$form
,
$form_state
);
//copied from core.
$message
=
'This is not a valid UUID.'
;
$form
[
'message'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'Message'
),
'#default_value'
=>
$this
->
configuration
[
'message'
]
??
$message
,
'#maxlength'
=>
255
,
];
return
$form
;
}
/**
* {@inheritdoc}
*/
public
function
submitConfigurationForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
parent
::
submitConfigurationForm
(
$form
,
$form_state
);
$this
->
configuration
[
'message'
]
=
$form_state
->
getValue
(
'message'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment