validation

custom validation error for two fields unique together django

蓝咒 提交于 2020-07-23 06:13:21
问题 i want to write my own validation error , for two fields unique together class MyModel(models.Model): name = models.CharField(max_length=20) second_field = models.CharField(max_length=10) #others class Meta: unique_together = ('name','second_field') and my forms.py class MyModelForm(forms.ModelForm): class Meta: model = MyModel fields = '__all__' error_messages= {#how to write my own validation error whenever `name and second_field` are unique together }: how to write my own validation error

Symfony 4 TextType required = false getting Expected argument of type “string”, “NULL” given

99封情书 提交于 2020-07-22 06:52:53
问题 I have a TextType field which is set as below Type: ->add('zipCode',TextType::class, array( 'attr' => array('maxlength' => 10), 'required' => false, 'empty_data' => null ) ) When the data loads from the database the field is null. I just attempt to submit the form and I get Expected argument of type "string", "NULL" given. at vendor/symfony/property-access/PropertyAccessor.php:174 at Symfony\Component\PropertyAccess\PropertyAccessor::throwInvalidArgumentException('Argument 1 passed to App

WPF Datagrid Multiple Row Validation

杀马特。学长 韩版系。学妹 提交于 2020-07-22 05:37:48
问题 Apologies if this question has already been asked, but I have not been able to find an answer to my specific problem. I have a WPF datagrid which is bound to a Collection of objects called Waypoint that implements IDataErrorInfo . Each Waypoint object a set of properties that have DataItem which also implements IDataErrorInfo . Each column in the datagrid is bound to the Value property of the DataItem object, and what I want is for the Waypoint object to be bound to the Row Validation

Disable validation when calling form for the first time

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-22 00:28:53
问题 I am struggling a bit with my Django forms. When I call my form site, always validation errors appear (this field is required). I'd prefer to see this message after clicking the submit button, if a field is not filled like a javascript function would do. In addition I'm using regex for validation, which is working fine. I am working with CVBs. Here is some code: models.py class Institute(models.Model): name = models.CharField(max_length=50) timestamp = models.DateTimeField(auto_now_add=True)

Detect the error message in the input field

和自甴很熟 提交于 2020-07-20 18:03:11
问题 How can I show the message if the user types a restricted symbol? For example, if the user types * in the input field, the error message can show A filename cannot contain any of the following characters: \/:*?"<>| . I hope someone can guide me how to do it. Thanks. <!DOCTYPE html> <html> <body> <h1>How to show error message</h1> <input type="text" class="form-control blank" id="function_code" name="function_code" title="function_code" onpaste="return false"> </body> </html> <script> document

Url validation attribute marks `localhost` as invalid Url

旧街凉风 提交于 2020-07-18 21:06:16
问题 In our ASP.MVC project we are using DataAnnotations attributes for validation. One of the fields should contains Url and it is marked with [Url] attribute. But if I put http://localhost:13030 into the field value it isn't passing the validation. Is there any way to use the attribute to define localhost as a valid target? 回答1: UrlAttribute validates against the RegEx shown in the source code here: https://github.com/Microsoft/referencesource/blob/master/System.ComponentModel.DataAnnotations

Url validation attribute marks `localhost` as invalid Url

孤街醉人 提交于 2020-07-18 21:05:24
问题 In our ASP.MVC project we are using DataAnnotations attributes for validation. One of the fields should contains Url and it is marked with [Url] attribute. But if I put http://localhost:13030 into the field value it isn't passing the validation. Is there any way to use the attribute to define localhost as a valid target? 回答1: UrlAttribute validates against the RegEx shown in the source code here: https://github.com/Microsoft/referencesource/blob/master/System.ComponentModel.DataAnnotations

ReactiveUI, WPF and Validation

梦想与她 提交于 2020-07-18 13:47:31
问题 I've seen that ReactiveUI had validation features in the past. Currently, with version 6.5, I cannot find anything related to it. Do you know if there's a more or less official way to deal with validation tasks in WPF using ReactiveUI? 回答1: Overall consensus on RxUI slack group is that people are exposing extra validation properties, e.g. split UserName and UserNameError (which is null if there is no error). Then use the platform’s validation/error mechanism to bring to user’s attention. 回答2:

ReactiveUI, WPF and Validation

时光总嘲笑我的痴心妄想 提交于 2020-07-18 13:47:02
问题 I've seen that ReactiveUI had validation features in the past. Currently, with version 6.5, I cannot find anything related to it. Do you know if there's a more or less official way to deal with validation tasks in WPF using ReactiveUI? 回答1: Overall consensus on RxUI slack group is that people are exposing extra validation properties, e.g. split UserName and UserNameError (which is null if there is no error). Then use the platform’s validation/error mechanism to bring to user’s attention. 回答2:

Groovy: validate JSON string

断了今生、忘了曾经 提交于 2020-07-18 04:09:26
问题 I need to check that a string is valid JSON in Groovy. My first thought was just to send it through new JsonSlurper().parseText(myString) and, if there was no exception, assume it was correct. However, I discovered that Groovy will happily accept trailing commas with JsonSlurper , but JSON doesn't allow trailing commas. Is there a simple way to validate JSON in Groovy that adhere's to the official JSON spec? 回答1: JsonSlurper class uses JsonParser interface implementations (with