Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: The XML Dating Service

    CodeSOD: The XML Dating Service

    July 9, 2025

    One of the endless struggles in writing reusable API endpoints is creating useful schemas to describe them. Each new serialization format comes up with new ways to express your constraints, each with their own quirks and footguns and absolute trainwrecks.

    Maarten has the “pleasure” of consuming an XML-based API, provided by a third party. It comes with an XML schema, for validation. Now, the XML Schema Language has a large number of validators built in. For example, if you want to restrict a field to being a date, you can mark it’s type as xsd:date. This will enforce a YYYY-MM-DD format on the data.

    If you want to ruin that validation, you can do what the vendor did:

    <span class="hljs-tag"><<span class="hljs-name">xsd:simpleType</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"DatumType"</span>></span>
      <span class="hljs-tag"><<span class="hljs-name">xsd:annotation</span>></span>
        <span class="hljs-tag"><<span class="hljs-name">xsd:documentation</span>></span>YYYY-MM-DD<span class="hljs-tag"></<span class="hljs-name">xsd:documentation</span>></span>
      <span class="hljs-tag"></<span class="hljs-name">xsd:annotation</span>></span>
      <span class="hljs-tag"><<span class="hljs-name">xsd:restriction</span> <span class="hljs-attr">base</span>=<span class="hljs-string">"xsd:date"</span>></span>
        <span class="hljs-tag"><<span class="hljs-name">xsd:pattern</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"(1|2)[0-9]{3}-(0|1)[0-9]-[0-3][0-9]"</span> /></span>
      <span class="hljs-tag"></<span class="hljs-name">xsd:restriction</span>></span>
    <span class="hljs-tag"></<span class="hljs-name">xsd:simpleType</span>></span>
    

    You can see the xsd:pattern element, which applies a regular expression to validation. And this regex will “validate” dates, excluding things which are definitely not dates, and allowing very valid dates, like February 31st, November 39th, and the 5th of Bureaucracy (the 18th month of the year), as 2025-02-31, 2025-11-39 and 2025-18-05 are all valid strings according to the regex.

    Now, an astute reader will note that this is a xsd:restriction on a date; this means that it’s applied in addition to ensuring the value is a valid date. So this idiocy is harmless. If you removed the xsd:pattern element, the behavior would remain unchanged.

    That leads us to a series of possible conclusions: either they don’t understand how XML schema restrictions work, or they don’t understand how dates work. As to which one applies, well, I’d say 1/3 chance they don’t understand XML, 1/3 chance they don’t understand dates, and a 1/3 chance they don’t understand both.

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleThe Rise of AI Analytics and What It Means for Industries
    Next Article Free Ad Text Generator

    Related Posts

    News & Updates

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

    September 12, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    5 AI Tools Revolutionizing Web Development

    Web Development

    Designing Scroll Behavior: When to Save a User’s Place

    Web Development

    Top 10 Technical SEO Service Providers

    Web Development

    These smart glasses can read menus and ‘see for you’, thanks to AI

    News & Updates

    Highlights

    Development

    AI Adoption in the Enterprise: Breaking Through the Security and Compliance Gridlock

    April 3, 2025

    AI holds the promise to revolutionize all sectors of enterpriseーfrom fraud detection and content personalization…

    PyPI Blocks 1,800 Expired-Domain Emails to Prevent Account Takeovers and Supply Chain Attacks

    August 19, 2025

    North Korean Konni APT Targets Ukraine with Malware to track Russian Invasion Progress

    May 13, 2025

    Laravel Demo Project for Beginners: Personal Blog

    June 17, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.