agentleFS
hellobrophyhellobrophy/claude-skills/form-validator/SKILL.md

form-validator

Skill0 starsChanged 7 months agoMITView on GitHub

Implement client-side form validation. Automatically loads when adding form validation, handling form errors, or improving form UX.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. Nikoxkx/Agent-Skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use aria-describedby to link inputs to error messages

    line 122
  2. Very specific:

    Use role="alert" on error containers

    line 123
  3. Distinctive:

    Don't rely only on color to indicate errors

    line 124
  4. Distinctive:

    Don't clear the form on validation failure

    line 126
  5. Distinctive:

    Always validate on the server

    line 131

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Form Validator Skill

This skill provides patterns for implementing robust client-side form validation.

Validation Patterns

Email Validation

const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

function isValidEmail(email) {
  return EMAIL_PATTERN.test(email);
}

Phone Validation

const PHONE_PATTERN = /^[\d\s\-+()]{10,}$/;

function isValidPhone(phone) {
  return PHONE_PATTERN.test(phone);
}

Required Field

function isRequired(value) {
  return value.trim().length > 0;
}

HTML Structure

Form Field with Validation

<div class="form-group">
  <label for="email" class="form-label"> Email <span class="required">*</span> </label>
  <input
    type="email"
    id="email"
    name="email"
    class="form-input"
    required
    aria-describedby="email-error"
    aria-invalid="false"
  />
  <span class="form-error" id="email-error" role="alert"></span>
</div>

Error Display Pattern

function showError(field, message) {
  const errorEl = document.getElementById(`${field.id}-error`);
  field.classList.add("is-invalid");
  field.setAttribute("aria-invalid", "true");
  if (errorEl) {
    errorEl.textContent = message;
  }
}

function clearError(field) {
  const errorEl = document.getElementById(`${field.id}-error`);
  field.classList.remove("is-invalid");
  field.setAttribute("aria-invalid", "false");
  if (errorEl) {
    errorEl.textContent = "";
  }
}

Validation Strategy

On Blur (Field Level)

field.addEventListener("blur", () => {
  if (field.hasAttribute("required") || field.value) {
    validateField(field);
  }
});

On Submit (Form Level)

form.addEventListener("submit", (event) => {
  event.preventDefault();

  const result = validateForm(form);

  if (!result.isValid) {
    const firstInvalid = form.querySelector(".is-invalid");
    if (firstInvalid) firstInvalid.focus();
    return;
  }

  submitForm(form);
});

Error Messages

ValidationBadGood
Required"Error""This field is required"
Email"Invalid""Please enter a valid email address"
Min length"Too short""Please enter at least 10 characters"

Accessibility Considerations

  1. Use aria-describedby to link inputs to error messages
  2. Use role="alert" on error containers
  3. Don't rely only on color to indicate errors
  4. Provide clear, actionable error messages
  5. Don't clear the form on validation failure

Security Notes

  • Client-side validation is for UX only
  • Always validate on the server
  • Sanitize inputs before display

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.