فهرست منبع

A terminar, validación para datos en YAML.

Maximiliano Schvindt 8 سال پیش
والد
کامیت
355a755e51

+ 12 - 0
src/WorkflowBundle/Validator/Constraints/ContainsYaml.php

@@ -0,0 +1,12 @@
+<?php
+namespace WorkflowBundle\Validator\Constraints;
+
+use Symfony\Component\Validator\Constraint;
+
+/**
+ * @Annotation
+ */
+class ContainsYaml extends Constraint
+{
+    public $message = 'workflow_error_yaml_format';
+}

+ 24 - 0
src/WorkflowBundle/Validator/Constraints/ContainsYamlValidator.php

@@ -0,0 +1,24 @@
+<?php
+namespace WorkflowBundle\Validator\Constraints;
+
+use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\ConstraintValidator;
+use Symfony\Component\Yaml\Yaml;
+
+class ContainsYamlValidator extends ConstraintValidator
+{
+    public function validate($value, Constraint $constraint)
+    {
+        $yaml = Yaml::dump($value,100,2);
+
+        
+        
+        
+        
+        // if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
+        //     $this->context->buildViolation($constraint->message)
+        //         ->setParameter('%string%', $value)
+        //         ->addViolation();
+        // }
+    }
+}