Skip to content

Add validations #9

@wasabigeek

Description

@wasabigeek

Ideally break into smaller PRs. Some discussion can be found at #4 (comment) - the proposed is to have the individual FieldInputs (could we rename to AttributeForm?) do the validation and only call onUpdate if the inputs are valid (sort of an uncontrolled component). I think we don't need to show an error in the command UI at this moment, just the form inputs.

We can follow https://tailwindui.com/components/application-ui/forms/input-groups#component-7a5297f99a5ed22df80939dd1986de5f, example HTML / classes:

<!--
  This example requires Tailwind CSS v2.0+ 
  
  This example requires some changes to your config:
  
  // tailwind.config.js
  module.exports = {
    // ...
    plugins: [
      // ...
      require('@tailwindcss/forms'),
    ]
  }
-->
<div>
  <label for="email" class="block text-sm font-medium text-gray-700">Email</label>
  <div class="mt-1 relative rounded-md shadow-sm">
    <input type="text" name="email" id="email" class="block w-full pr-10 border-red-300 text-red-900 placeholder-red-300 focus:outline-none focus:ring-red-500 focus:border-red-500 sm:text-sm rounded-md" placeholder="[email protected]" value="adamwathan" aria-invalid="true" aria-describedby="email-error">
    <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
      <!-- Heroicon name: solid/exclamation-circle -->
      <svg class="h-5 w-5 text-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
        <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
      </svg>
    </div>
  </div>
  <p class="mt-2 text-sm text-red-600" id="email-error">Your password must be less than 4 characters.</p>
</div>

Model Generator

  • model name should be CamelCased or under_scored only
  • attribute name is required
  • does attribute name need to be under_scored?
  • field type is required
  • limit / precision / scale modifiers should be positive integers only
  • reserved attribute names e.g. type is used for single table inheritance

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions