Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- }
- [ValidationSchema("person.xsd")]
- public class Person { /* ... */ }
- <!-- person.xsd -->
- <?xml version="1.0"?>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsd:element name="Person" type="PersonType" />
- <xsd:simpleType name="NameString">
- <xsd:restriction base="xsd:string">
- <xsd:maxLength value="255"/>
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="PersonType">
- <xsd:sequence>
- <xsd:element name="FirstName" type="NameString" maxOccurs="1"/>
- <xsd:element name="LastName" type="NameString" maxOccurs="1"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:schema>
- using System.ComponentModel.DataAnnotations;
- public class Person
- {
- [StringLength(255, ErrorMessage = "Error")]
- public string FirstName { get; set; }
- [StringLength(255, ErrorMessage = "Error")]
- public string LastName { get; set; }
- }
Add Comment
Please, Sign In to add comment