-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new txt-1 and txt-2 validation components #181
Added new txt-1 and txt-2 validation components #181
Conversation
|
||
if (input.Value is null) return (false, null); | ||
|
||
var result = XHtml.IsValidNarrativeXhtml(input.Value.ToString(), out var errors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't trust the input.Value.ToString(), since that's calling the object.ToString
function, which might or might not be implemented correctly. Better check that input.Value
is actually of type string (as it should be for divs) and just return (false,null) if not (it should only have been generated on elements of the right type). Although I remember another issue where we want to protest if we are run on an invalid value. Double check if other validators do the same when an unexpected datatype arrives in Value
.
var results = narrativeSchema!.Validate(justWhiteSpace.ToTypedElement(), _fixture.NewValidationContext()); | ||
results.IsSuccessful.Should().Be(false, "Instance failed constraint txt-2 \"The narrative SHALL have some non-whitespace content\""); | ||
|
||
results = narrativeSchema!.Validate(invalidHtml.ToTypedElement(), _fixture.NewValidationContext()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be really sure this invariant works, you need to use a forbidden html feature according to the XHTML spec for narrative, e.,g:
The XHTML content SHALL NOT contain a head, a body element, external stylesheet references, deprecated elements, scripts, forms, base/link/xlink, frames, iframes, objects or event related attributes (e.g. onClick).
fixes #141