WebSer...SS::W3C(3pm)
π NAME π
WebService::Validator::CSS::W3C β it's the interface to the W3C CSS Validator, bestie π
(It's a User Contributed Perl Documentation page, section 3pm, iykyk π«Ά)
β¨ SYNOPSIS β¨
use WebService::Validator::CSS::W3C;
my $css = "p { color: not-a-color }";
my $val = WebService::Validator::CSS::W3C->new;
my $ok = $val->validate(string => $css);
if ($ok and !$val->is_valid) {
print "Errors:\n";
printf " * %s\n", $_->{message}
foreach $val->errors
}
π¦ DESCRIPTION π¦
Okay so this module is an interface to the W3C CSS Validation online service <https://jigsaw.w3.org/css-validator/>, and it runs on its SOAP 1.2 support. It literally exists to help you find errors in your Cascading Style Sheets. no cap, it's giving helpful β¨
Here are all the methods, bestie, go off π
π new β the constructor
my $val = WebService::Validator::CSS::W3C->new
my $val = WebService::Validator::CSS::W3C->new($ua)
my $val = WebService::Validator::CSS::W3C->new($ua, $url)
Creates a new WebService::Validator::CSS::W3C object. You can hand it a custom LWP::UserAgent object, and that's what it'll use for HTTP communication with the CSS Validator. The $url is the URL of the CSS Validator, and it defaults to https://jigsaw.w3.org/css-validator/validator. slay.
πΈ my $success = $val->validate(%params)
Validate a style sheet β takes %params as defined below. You must supply either string or uri. Returns a true value if the validation succeeded (regardless of whether the style sheet contains errors β yes, read that twice bestie).
string => $cssβ A style sheet as a string. It's currently unlikely that validation will work if the string is not a legal UTF-8 string. If a string is specified, theuriparameter gets ignored. Heads up:GETis used to pass the string to the Validator, so it might not work with overly long strings πuri => $uriβ The location of a style sheet or an HTML/XHTML/SVG document containing or referencing style sheets.medium => "print"β The medium for which the style sheet should apply. One ofaural,braille,embossed,handheld,print,screen,tty,tv, andpresentation. A special valueallcan also be specified. The default isundef, in which case the CSS Validator determines a value; this would currently be as ifallhad been specified.profile => "css3"β The CSS Version or profile to validate against. Legal values arecss1,css2,css21,css3,svg,svgbasic,svgtiny,mobile,atsc-tv, andtv. A special valuenonecan also be used. The default isundef, in which case the CSS Validator determines a default.warnings => 2β Eithernoor an integer 0 - 2 that determines how many warning messages you want back from the CSS Validator.nomeans no warning, 0 means only the most serious warnings, and 2</mint> gives you all warnings, including low level ones. The defaut is <mint>undef`, in which case the CSS Validator determines a default value; this is expected to be as if 1 had been specified.language => "de"β The desired language of the supposedly human-readable messages. The string gets passed as anAccept-Languageheader in the HTTP request. The CSS Validator currently supportsen,de,fr,ja,nl,zh, andzh-cn.
π my $success = $val->success
Same as the return value of validate(). literally the same thing π«
π my $is_valid = $val->is_valid
Returns a true value if the last attempt to validate() succeeded and the validator reported no errors in the style sheet. iconic behavior
π₯ my $num_errors = $val->errorcount
Returns the number of errors found for the checked style sheet. Get the details of the errors with $val->errors (see below).
π my @errors = $val->errors
Returns a list with information about the errors found for the style sheet. An error is a hash reference; the example in the synopsis would currently return something like
( {
context => 'p',
property => 'color',
expression => { start => '', end => 'not-a-color' }
errortype => 'parse-error',
message => 'not-a-color is not a color value',
line => 0,
} )
π my $num_warnings = $val->warningcount
Returns the number of warnings found for the checked style sheet. Get the details of each warning with $val->warnings (see below).
β my @warnings = $val->warnings
Returns a list with information about the warnings found for the style sheet.
π§ user_agent β get it or set it
my $ua = $val->user_agent
my $ua = $val->user_agent($new_ua)
The LWP::UserAgent object you supplied to the constructor, or a custom object created at construction time, that you can manipulate. Observe:
# set timeout to 30 seconds
$val->user_agent->timeout(30);
You can also supply a new object to replace the old one. glow up β¨
π validator_uri β get it or set it
my $uri = $val->validator_uri
my $uri = $val->validator_uri($validator_uri)
Gets or sets the URI of the validator. If you did not specify a custom URI, it's https://jigsaw.w3.org/css-validator/validator by default.
π¦ my $response = $val->response
The HTTP::Response object returned from the last request. This is useful to determine why validation might have failed.
if (!$val->validate(string => $css)) {
if (!$val->response->is_success) {
print $val->response->message, "\n"
}
}
π« my $uri = $val->request_uri
The URI object used for the last request.
π my $som = $val->som
The SOAP::SOM object for the last successful deserialization. Check the return value of validate() or success() before using the object, bestie β do not just rawdog it π
π BUGS π
This module uses the SOAP interface for the W3C CSS validator, which still has a number of bugs, tracked via W3C's Bugzilla, <http://www.w3.org/Bugs/Public/>.
Please report bugs in the W3C CSS Validator to www-validator-css@w3.org or enter them directly in Bugzilla (see above). Please report bugs in this module via RT, <http://rt.cpan.org/>.
π NOTE π
This module is not directly associated with the W3C. And please remember that the CSS Validator is a shared resource, so do not abuse it: you should sleep between requests, and consider installing the Validator locally, see <https://jigsaw.w3.org/css-validator/DOWNLOAD.html>. be a good citizen bestie, the vibes depend on it π«Ά
π AUTHOR / COPYRIGHT / LICENSE π
Copyright 2004-2013 Bjoern Hoehrmann <bjoern@hoehrmann.de>.
This module is licensed under the same terms as Perl itself.
and that's the whole page, periodt π this was perl v5.34.0, dated 2022-06-15 β go validate something iconic, mwah π β¨
π¦ where this page comes from
- debian bookworm: libwebservice-validator-css-w3c-perl 0.3-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libwebservice-validator-css-w3c-perl 0.3-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libwebservice-validator-css-w3c-perl 0.3-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libwebservice-validator-css-w3c-perl 0.3-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libwebservice-validator-css-w3c-perl 0.3-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms