public void Decorate(object attribute, DisplayMetadata modelMetaData) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (!(attribute is StringLengthAttribute)) { throw new ArgumentException("Attribute type is not StringLengthAttribute", nameof(attribute)); } var stringLengthttribtue = (StringLengthAttribute)attribute; modelMetaData.AddAdditionalValueWithValidationMessage("Maxlength", stringLengthttribtue.MaximumLength, stringLengthttribtue); if (stringLengthttribtue.MinimumLength > 0) { modelMetaData.AddAdditionalValueWithValidationMessage("Minlength", stringLengthttribtue.MinimumLength, stringLengthttribtue); } }
public void Decorate(object attribute, DisplayMetadata modelMetaData) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (!(attribute is RangeAttribute)) { throw new ArgumentException("Attribute type is not RangeAttribute", nameof(attribute)); } var rangeLengthttribtue = (RangeAttribute)attribute; string minAttribute = null; string maxAttribute = null; if (rangeLengthttribtue.OperandType == typeof(string)) { minAttribute = "Minlength"; maxAttribute = "Maxlength"; } else { minAttribute = "Min"; maxAttribute = "Max"; } if (minAttribute != null) { if (rangeLengthttribtue.Minimum != null) { modelMetaData.AddAdditionalValueWithValidationMessage(minAttribute, rangeLengthttribtue.Minimum, rangeLengthttribtue); } if (rangeLengthttribtue.Maximum != null) { modelMetaData.AddAdditionalValueWithValidationMessage(maxAttribute, rangeLengthttribtue.Maximum, rangeLengthttribtue); } } }
public void Decorate(object attribute, DisplayMetadata modelMetaData) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); if (!(attribute is MaxLengthAttribute)) { throw new ArgumentException("Attribute type is not MaxLengthAttribute", nameof(attribute)); } var maxLengthttribtue = (MaxLengthAttribute)attribute; modelMetaData.AddAdditionalValueWithValidationMessage("Maxlength", maxLengthttribtue.Length, maxLengthttribtue); }
public void Decorate(object attribute, DisplayMetadata modelMetaData) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (!(attribute is CompareAttribute)) { throw new ArgumentException("Attribute type is not CompareAttribute", nameof(attribute)); } var compareAttribtue = (CompareAttribute)attribute; var otherProperty = compareAttribtue.OtherProperty; var valAttribute = compareAttribtue; modelMetaData.AddAdditionalValueWithValidationMessage("Match", otherProperty, valAttribute); }