Giter Site home page Giter Site logo

clavier's Issues

error-p option in make-instance

I want to use validator like this

(let ((validator (make-instance 'boolean-validator :error-p t)))
    (funcall validator "hi"))
=> #<VALIDATION-ERROR hi: hi is not a boolean {1003B01EF3}>

What do you say to this option?

How would you allow a blank field and validate if non blank?

Say we have a form field that can be empty, but when non empty it should be validated. Can we express that?

I tried with a || and non-blank or blank but it isn't the right logic.

Is this expected to be done on this layer?


I can add this meaning on my side, but this looks like it should be done inside the validation library.

(defun my-validators ()
  (dict 'isbn (list :allow-blank
                    (clavier:not-blank)
                    (clavier:len :min 10 :max 13))
  …))

…

      (loop for validator in (validators)
            if (and (eql :allow-blank validator)
                    (str:blankp val))
              return t
            else
              do (unless (keywordp validator)
                   (multiple-value-bind (success msg)
                       (clavier:validate validator val)
                     …

Best,


I tried to create a new validator class, but this won't compile:

Cannot CHANGE-CLASS objects into CLASS metaobjects.

(defclass allow-blank-validator (validator)
  ()
  (:metaclass closer-mop:funcallable-standard-class))

LEN validator: no message, min-message and max-message are not displayed

Hello,

it seems that :min-message and :max-message are not displayed. Also why not have a :message?

(defun len (&key min max message min-message max-message)
  (make-instance 'length-validator
		 :min min
		 :max max
                 :message message  <---- adding message but this creates an error on validation.
		 :min-message min-message
		 :max-message max-message))

(will send PR later if I confirm the needs)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.