How to solve Symfony 4 Password null error? - symfony

I have a form which has a Repeat password. On blank submission, I get the following error.
Expected argument of type "string", "NULL" given at property path "password".
UserType:
$builder
->add('email',TextType::class)
->add('password',RepeatedType::class,
[
'type'=>PasswordType::class,
'required'=> false,
'invalid_message' => 'The password fields must match.',
'empty_data'=> ''
])
->add('firstname',TextType::class)
->add('lastname',TextType::class)
->add('submit', SubmitType::class)
;
When I insert the value in either password field I get the validation message, but if I keep both blanks I get the above-written error.

Related

Token XRPL listing

I am trying to list a token of XRPL, set truct and receive the following
"error_message" => "Field 'tx_json.LimitAmount' has invalid data."
"request" => array:5 [▼
"command" => "submit"
"fee_mult_max" => 1000
"offline" => false
"secret" => "<masked>"
"tx_json" => array:6 [▼
"Account" => "rX49UBNi94tCCt2jb7tHVjdYSVwHNhQK2"
"DestinationTag" => 1
"Fee" => "15000"
"Flags" => 262144
"LimitAmount" => array:3 [▼
"currency" => "Xoge"
"issuer" => "rJMtvf5B3GbuFMrqybh5wYVXEH4QE8VyU1"
"value" => "1000000000000000"
]
"TransactionType" => "TrustSet"
]
]
"status" => "error"
using this document: https://xrpl.org/trustset.html
XRP Ledger supports either a three-letter ISO 4217 Currency Code or a 160-bit(40-character) hexadecimal string as value for "currency" field.
In your case(above code), you are using "Xoge" as value for the field "currency" inside "LimitAmount" object. "Xoge" has more than 3 letters, so it's throwing error. You can either switch to a 3 letter currency code or convert "Xoge" into 160-bit(40-character) hexadecimal string.
LimitAmount: {
currency: '586F676500000000000000000000000000000000',
issuer: 'rJMtvf5B3GbuFMrqybh5wYVXEH4QE8VyU1',
value: '1000000000000000'
},
Here 586F676500000000000000000000000000000000 represents Xoge in 160-bit hex.
Couple of more things I noticed from your code:
Fee is represented in drops. So you can lower your fee a bit, and it'll still work.
You are setting flag 262144 which enables rippling. Usually TrustLine is setup by regular users with the issuer, so it's always recommended to have flag 131072, which blocks rippling from the user end of the TrustLine.

DynamoDB UpdateItem with ReturnValues parameter returns nothing on failed ConditionExpression

Using aws/aws-sdk-php 3.21.6. I must be misunderstanding how ReturnValues works when a ConditionExpression meets the ConditionalCheckFailedException error.
What I'm hoping is that if the ConditionExpression fails, which in turn triggers the ConditionalCheckFailedException, that I can catch this exception and then get access via ReturnValues to the new Attributes from DD.
The docs Attributes I'm expecting from ReturnValues seem to imply this.
From testing, however, ReturnValues only returns Attributes if the ConditionExpression is true, not when it fails.
$response = $client->updateItem([
'TableName' => 'MyTable',
'Key' => [
'customer_url' => [
'S' => 'someurl.com'
],
'customer_platform' => [
'S' => 'some_platform'
]
],
'ExpressionAttributeNames' => [
'#C' => 'createdAt'
],
'ExpressionAttributeValues' => [
':val1' => [
'S' => '2017-01-24T14:15:32'
],
':val2' => [
'S' => '2017-01-24T14:15:30'
]
],
'UpdateExpression' => 'set #C = :val1',
'ConditionExpression' => '#C = :val2', // :val2 originally was 2017-01-24T14:15:30, before attempting to update to 2017-01-24T14:15:32. If I change the field to 2017-01-24T14:15:31, before running this update it will throw the ConditionalCheckFailedException
'ReturnValues' => 'ALL_NEW'
]);
Yes, ReturnValues is populated only if an updateItem succeeds. If it fails, because of ConditionalCheckFailedException or any other reason, ReturnValues will be null.
Supporting documentation from here, with emphasis mine:
Use ReturnValues if you want to get the item attributes as they appeared either before or after they were updated.

Accessing nested parameters in Symfony ParameterBag

Have a request that looks like this
ParameterBag {#362 ▼
#parameters: array:1 [▼
"form" => array:5 [▼
"titre" => "new b"
"prix" => "4444"
"slug" => "with-different-slug"
"publier" => "unpub"
"Modifier" => ""
]
]
}
How can I use the
$post = Request::createFromGlobals();
$post->request->has() on those nested properties?
ParameterBag's has function does not support deep check. It is just an array_key_exists call.
You could use get with $deep parameter set to true.
E.g.:
$post = Request::createFromGlobals();
$post->request->get('form[titre]', null, true);
It will return null (the second parameter), if the value does not exist.
EDIT:
This function however deprecated in 2.8.
Using paths to find deeper items in get is deprecated since version 2.8 and will be removed in 3.0. Filter the returned value in your own code instead.

Spring 3: Making the web-application accept null parameter for multipartfile argument

Currently, when the file parameter is null or empty in the form, the web application throws an error. I have even checked for the case when file is empty but it doesn’t seem to work. Does anyone know how to check for the case when the filename field in the form is empty and not throw an error in the web app?
I am using the following code for controller. As you can see I accept a Multi-part file parameter, which is the file uploaded in the form.
#RequestMapping(value="/attachment", method=RequestMethod.POST)
public String sendAttachment(#RequestHeader("Authorization") String authHeader, #RequestParam("to") String to,#RequestParam("cc") String cc,#RequestParam("bcc") String bcc,#RequestParam("subject") String subject,#RequestParam("body") String body, #RequestParam("file") MultipartFile file,#RequestParam("filename") String filename) {
. . .
//here i check if the file is empty...if not empty, then only attach it in the message.
if(!file.isEmpty())
{
msg.getAttachments().addFileAttachment(filename,file.getBytes());
}
. . .
The php file I am using to call this web service is as follows:
Following is the form post parameters sent to the web service with empty file param
$params = array(
'to' => null,
'cc' => null,
'bcc' => "sanjaygir#gmail.com",
'subject' => "hola sanjayg",
'body' => "just testing message service",
'filename'=> "",
'file'=>""
);
I have also tried using null:
$params = array(
'to' => null,
'cc' => null,
'bcc' => "sanjaygir#gmail.com",
'subject' => "hola sanjayg",
'body' => "just testing message service",
'filename'=> null,
'file'=>null
);
Still it throws 500 error in the server.
Try to change #RequestParam("file") MultipartFile file to #RequestParam(value = "file", required=false) MultipartFile file

Symfony 2 - Validate a field with NotBlank & Type constraints

I am having problems validating a form component when i have added both NotBlank and Type validation to an integer field.
My validation.yml looks like the following:
Acme\StoreBundle\Entity\Foo:
properties:
bar:
- NotBlank:
message: You must specify a bar
- Type:
type: integer
message: bar must be an integer
My FormType file looks like the following:
$builder->add('bar', 'integer', array(
'label' => bar',
'error_bubbling' => true
));
When I type 'abc' into the field and submit, validate the form and getErrors(), the errors reported are -
This value is not valid.
You must specify a bar.
any ideas whats going wrong? I'm running Symfony 2.0.10
I had the same problem. In the end, I used a normal 'text' field, and made my own 'Integer' validator which uses regular expression.
I am not sure but maybe this helps:
$builder->add('bar', 'integer', array(
'label' => bar',
'invalid_message' => 'bar must be an integer'
'error_bubbling' => true
));
Check this out
Your problem may be related to this issue. From the discussion of the issue it seems that the solution of the problem is replacing line 40 of the DelegatingValidator.php with this code
if ($form->isRoot() && $form->isSynchronized()) {
I haven't tested it though. You can try and tell about the result :).
I am pretty late but this can help
validation.yml
contactNo:
- NotBlank: ~
- Regex:
pattern: '/\d/'
match: true
message: Your contact no. must be a number
- Length:
min: 10
max: 15
minMessage: 'You contact no. must be at least {{ limit }} digits.'
maxMessage: 'You contact no. can not be greater than {{ limit }} digits.'

Resources