validationrules

WPF - ValidationRule is not being called

可紊 提交于 2019-12-11 19:19:34
问题 I got this Xaml of a TextBlock: <TextBlock VerticalAlignment="Center"> <TextBlock.Text> <Binding Path="FilesPath" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <viewModel:ExtensionRule></viewModel:ExtensionRule> </Binding.ValidationRules> </Binding> </TextBlock.Text> </TextBlock> In the ViewModel: private string _filesPath; public string FilesPath { set { _filesPath = value; OnPropertyChange("FilesPath"); } get { return _filesPath; } } private void

Enum in custom web test validation rule

∥☆過路亽.° 提交于 2019-12-08 10:02:44
问题 I'm building a Web Test using Microsoft VS2010. I used the explanation on MSDN: How to: Create a Custom Validation Rule for a Web Performance Test. In the example there using string and int as private members with public "get" and "set" those parameters valid for edit in the UI when I add this validation rule to my test. I want to have an Enum with 3 option that when I add the validation rule to the UI I can choose from. Is there a way to add an Enum variable which will also be valid in the

WPF DependencyProperty Validation Binding to the object property

最后都变了- 提交于 2019-12-07 17:59:30
I am trying to create a validation rule for a given control (in this scenario, it is the TextBox). I am not able to obtain a successful Binding to the property of an object, although appropriate steps were taken: ValidationRule and DepedencyProperty are taken advantage of. Kindly find code below. A side note is that "Is Required" in the custom Validation class is always False, unless I explicitly set the value in the XAML (no Binding, as per "Is Ranged" parameter). Any tips and suggestions are appreciated. Thank you in advance :) XAML Code: <TextBox Style="{StaticResource ValidationError}"

How to specify a validation rule in Yii2 which will be greater than or less than of a specific number or value?

痞子三分冷 提交于 2019-12-07 01:26:03
问题 I have a model with a validation rule like: [['x'], 'integer'], [['x'], 'unique'], Now how can I add a rule like: x < 100 or something like x >= 100 回答1: It should be: ['x', 'compare', 'compareValue' => 100, 'operator' => '<'], and ['x', 'compare', 'compareValue' => 100, 'operator' => '>='], accordingly. Read more in official docs. 回答2: You could also use the min attribute on number, or integer validators: ['age', 'integer', 'min' => 0], ['amount', 'number', 'min' => 0], There is also a max

Multiple Validation Rules and Validation Templates in WPF

别来无恙 提交于 2019-12-05 21:12:18
Does anyone have a tactic for dealing with multiple validation rules and templates for those validation rules. Example: I want to have two validation rules (required & data) I want either... One template that can change is display depending on which rule is fired or Two templates, which get displayed depending on which rule is fired Ok, so I've figured out an approach that works and I was hoping to get feedback from anyone that might have an interest in this. ValidationRule: My validation rule is altered to send back an "ErrorObject" that has IsRequired & Message properties public class

How to specify a validation rule in Yii2 which will be greater than or less than of a specific number or value?

社会主义新天地 提交于 2019-12-05 04:47:35
I have a model with a validation rule like: [['x'], 'integer'], [['x'], 'unique'], Now how can I add a rule like: x < 100 or something like x >= 100 It should be: ['x', 'compare', 'compareValue' => 100, 'operator' => '<'], and ['x', 'compare', 'compareValue' => 100, 'operator' => '>='], accordingly. Read more in official docs . You could also use the min attribute on number, or integer validators: ['age', 'integer', 'min' => 0], ['amount', 'number', 'min' => 0], There is also a max option. Yii2 greater than validation : field_to must be greater than "field_from". Field 1 : field_from Field 2 :

ValidationRules without binding

你离开我真会死。 提交于 2019-11-30 11:24:43
I want to use the ValidationRules (and it's UI effects) on the textbox without actually binding anything to the textbox. I want to use the textbox for some input that doesn't bound to anything but need to validate the input after focus is lost using the ValidationRules. Can it be done? <TextBox.Text> <Binding Path="" UpdateSourceTrigger="LostFocus"> <Binding.ValidationRules> <local:IntegersOnlyValidator/> </Binding.ValidationRules> </Binding> </TextBox.Text> This worked for me: <TextBox.Text> <Binding RelativeSource="{RelativeSource Self}" Path="Text" UpdateSourceTrigger="LostFocus"> <Binding

ValidationRules without binding

只谈情不闲聊 提交于 2019-11-29 16:57:01
问题 I want to use the ValidationRules (and it's UI effects) on the textbox without actually binding anything to the textbox. I want to use the textbox for some input that doesn't bound to anything but need to validate the input after focus is lost using the ValidationRules. Can it be done? <TextBox.Text> <Binding Path="" UpdateSourceTrigger="LostFocus"> <Binding.ValidationRules> <local:IntegersOnlyValidator/> </Binding.ValidationRules> </Binding> </TextBox.Text> 回答1: This worked for me: <TextBox

Validation Framework in .NET that can do edits between fields

不想你离开。 提交于 2019-11-29 08:01:08
From my experience many validation frameworks in .NET allow you to validate a single field at a time for doing things like ensuring a field is a postal code or email address for instance. I usually call these within-field edits. In my project we often have to do between-field-edits though. For instance, if you have a class like this: public class Range { public int Min { get; set; } public int Max { get; set; } } you might want to ensure that Max is greater than Min. You might also want to do some validation against an external object. For instance given you have a class like this: public

Javascript Regex to limit Text Field to only Numbers (Must allow non-printable keys)

一个人想着一个人 提交于 2019-11-29 07:19:45
I have received PHP/JS code from previous developer and I need to add number validation to a Mobile Number field. I already have the HTML validation in place but I need to add that if someone presses an invalid key, that it doesn't get displayed only to highlight the field later in red because it contains invalid input. I've seen many regex's used and tried them but they had an either/or effect from what I need which is: If a letter or special character is entered, do not accept and do not display, all other input (digits, keys) is accepted (I need the invalid character not be displayed at all